org.apache.struts.tiles.definition
Class ReloadableDefinitionsFactory

java.lang.Object
  |
  +--org.apache.struts.tiles.definition.ReloadableDefinitionsFactory
All Implemented Interfaces:
ComponentDefinitionsFactory, java.io.Serializable

public class ReloadableDefinitionsFactory
extends java.lang.Object
implements ComponentDefinitionsFactory

A reloadable factory. This factory is the main entrance to any factory implementation. It takes in charge real implementation instance, and allows reloading by creating a new instance.

Since:
Struts 1.1
Version:
$Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
See Also:
Serialized Form

Inner Class Summary
(package private)  class ReloadableDefinitionsFactory.ServletPropertiesMap
          Inner class.
 
Field Summary
static java.lang.String DEFINITIONS_FACTORY_CLASSNAME
          Name of init property carrying factory class name.
protected  ComponentDefinitionsFactory factory
          The real factory instance.
protected  java.util.Map properties
          Initialization parameters.
 
Constructor Summary
ReloadableDefinitionsFactory(javax.servlet.ServletContext servletContext, java.util.Map properties)
          Constructor.
ReloadableDefinitionsFactory(javax.servlet.ServletContext servletContext, javax.servlet.ServletConfig servletConfig)
          Constructor.
 
Method Summary
 ComponentDefinitionsFactory createDefaultFactory(javax.servlet.ServletContext servletContext, java.util.Map properties)
          Create default Definition factory.
 ComponentDefinitionsFactory createFactory(javax.servlet.ServletContext servletContext, java.util.Map properties)
          Create Definition factory.
 ComponentDefinitionsFactory createFactoryFromClassname(javax.servlet.ServletContext servletContext, java.util.Map properties, java.lang.String classname)
          Create Definition factory from provided classname.
 ComponentDefinition getDefinition(java.lang.String definitionName, javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)
          Get a definition by its name.
 ComponentDefinitionsFactory getFactory()
          Get underlying factory instance.
 void initFactory(javax.servlet.ServletContext servletContext, java.util.Map properties)
          Init factory.
 void reload(javax.servlet.ServletContext servletContext)
          Reload underlying factory.
 java.lang.String toString()
          Return String representation.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

factory

protected ComponentDefinitionsFactory factory
The real factory instance.

properties

protected java.util.Map properties
Initialization parameters.

DEFINITIONS_FACTORY_CLASSNAME

public static final java.lang.String DEFINITIONS_FACTORY_CLASSNAME
Name of init property carrying factory class name.
Constructor Detail

ReloadableDefinitionsFactory

public ReloadableDefinitionsFactory(javax.servlet.ServletContext servletContext,
                                    javax.servlet.ServletConfig servletConfig)
                             throws DefinitionsFactoryException
Constructor. Create a factory according to servlet settings.
Parameters:
servletContext - Our servlet context.
servletConfig - Our servlet config.
Throws:
DefinitionsFactoryException - If factory creation fail.

ReloadableDefinitionsFactory

public ReloadableDefinitionsFactory(javax.servlet.ServletContext servletContext,
                                    java.util.Map properties)
                             throws DefinitionsFactoryException
Constructor. Create a factory according to servlet settings.
Parameters:
servletContext - Our servlet context.
properties - Map containing all properties.
Throws:
DefinitionsFactoryException - If factory creation fail.
Method Detail

createFactoryFromClassname

public ComponentDefinitionsFactory createFactoryFromClassname(javax.servlet.ServletContext servletContext,
                                                              java.util.Map properties,
                                                              java.lang.String classname)
                                                       throws DefinitionsFactoryException
Create Definition factory from provided classname. If a factory class name is provided, a factory of this class is created. Otherwise, a default factory is created. Factory must have a constructor taking ServletContext and Map as parameter.
Parameters:
classname - Class name of the factory to create.
servletContext - Servlet Context passed to newly created factory.
properties - Map of name/property passed to newly created factory.
Returns:
newly created factory.
Throws:
DefinitionsFactoryException - If an error occur while initializing factory

createDefaultFactory

public ComponentDefinitionsFactory createDefaultFactory(javax.servlet.ServletContext servletContext,
                                                        java.util.Map properties)
                                                 throws DefinitionsFactoryException
Create default Definition factory. Factory must have a constructor taking ServletContext and Map as parameter. In this implementation, default factory is of class I18nFactorySet
Parameters:
servletContext - Servlet Context passed to newly created factory.
properties - Map of name/property passed to newly created factory.
Returns:
newly created factory.
Throws:
DefinitionsFactoryException - If an error occur while initializing factory

createFactory

public ComponentDefinitionsFactory createFactory(javax.servlet.ServletContext servletContext,
                                                 java.util.Map properties)
                                          throws DefinitionsFactoryException
Create Definition factory. Convenience method. ServletConfig is wrapped into a Map allowing retrieval of init parameters. Factory classname is also retrieved, as well as debug level. Finally, approriate createDefinitionsFactory() is called.
Parameters:
servletContext - Servlet Context passed to newly created factory.
properties - Map containing all properties.

getDefinition

public ComponentDefinition getDefinition(java.lang.String definitionName,
                                         javax.servlet.ServletRequest request,
                                         javax.servlet.ServletContext servletContext)
                                  throws FactoryNotFoundException,
                                         DefinitionsFactoryException
Get a definition by its name. Call appropriate method on underlying factory instance. Throw appropriate exception if definition or definition factory is not found.
Specified by:
getDefinition in interface ComponentDefinitionsFactory
Parameters:
definitionName - Name of requested definition.
request - Current servlet request.
servletContext - Current servlet context.
Throws:
FactoryNotFoundException - Can't find definition factory.
DefinitionsFactoryException - General error in factory while getting definition.

reload

public void reload(javax.servlet.ServletContext servletContext)
            throws DefinitionsFactoryException
Reload underlying factory. Reload is done by creating a new factory instance, and replacing the old instance with the new one.
Parameters:
servletContext - Current servlet context.
Throws:
DefinitionsFactoryException - If factory creation fails.

getFactory

public ComponentDefinitionsFactory getFactory()
Get underlying factory instance.
Returns:
ComponentDefinitionsFactory

initFactory

public void initFactory(javax.servlet.ServletContext servletContext,
                        java.util.Map properties)
                 throws DefinitionsFactoryException
Init factory. This method is required by interface ComponentDefinitionsFactory. It is not used in this implementation, as it manages itself the underlying creation and initialization.
Specified by:
initFactory in interface ComponentDefinitionsFactory
Parameters:
servletContext - Servlet Context passed to newly created factory.
properties - Map of name/property passed to newly created factory. Map can contain more properties than requested.
Throws:
DefinitionsFactoryException - An error occur during initialization.

toString

public java.lang.String toString()
Return String representation.
Overrides:
toString in class java.lang.Object
Returns:
String representation.


Copyright 2000-2006 - The Apache Software Foundation