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 reload of it by creating a new instance.

Since:
1.1
Version:
$Revision: 1.2 $ $Date: 2002/07/11 16:48:46 $
Author:
Cedric Dumoulin
See Also:
Serialized Form

Nested 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()
          Get this object as a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

See Also:
Constant Field Values
Constructor Detail

ReloadableDefinitionsFactory

public ReloadableDefinitionsFactory(javax.servlet.ServletContext servletContext,
                                    javax.servlet.ServletConfig servletConfig)
                             throws DefinitionsFactoryException
Constructor. Create a factory according to servlet settings.

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.

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, 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.
DefinitionsFactoryException

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:
request - Current servelet request
servletContext - current servlet context
definitionName - Name of requested definition.
Throws:
FactoryNotFoundException - Can't find definition factory.
DefinitionsFactoryException - General error in factory while getting definition.
NoSuchDefinitionException - No definition found for specified name

reload

public void reload(javax.servlet.ServletContext servletContext)
            throws DefinitionsFactoryException
Reload underlying factory. Reload is done creating a new factory instance, and replacing old instance by the new one.

Parameters:
servletContext - current servlet context
Throws:
DefinitionsFactoryException - If factory creation fail.

getFactory

public ComponentDefinitionsFactory getFactory()
Get underlying factory instance.


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 manage itself 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 contains more properties than requested.
Throws:
DefinitionsFactoryException - An error occur during initialization.

toString

public java.lang.String toString()
Get this object as a String

Overrides:
toString in class java.lang.Object


Copyright 2000-2002 - Cedric Dumoulin and Apache Software Foundation