org.apache.struts.tiles.definition

Class ReloadableDefinitionsFactory

public class ReloadableDefinitionsFactory extends 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) $

Nested Class Summary
classReloadableDefinitionsFactory.ServletPropertiesMap
Inner class.
Field Summary
static StringDEFINITIONS_FACTORY_CLASSNAME
Name of init property carrying factory class name.
protected ComponentDefinitionsFactoryfactory
The real factory instance.
protected Mapproperties
Initialization parameters.
Constructor Summary
ReloadableDefinitionsFactory(ServletContext servletContext, ServletConfig servletConfig)
Constructor.
ReloadableDefinitionsFactory(ServletContext servletContext, Map properties)
Constructor.
Method Summary
ComponentDefinitionsFactorycreateDefaultFactory(ServletContext servletContext, Map properties)
Create default Definition factory.
ComponentDefinitionsFactorycreateFactory(ServletContext servletContext, Map properties)
Create Definition factory.
ComponentDefinitionsFactorycreateFactoryFromClassname(ServletContext servletContext, Map properties, String classname)
Create Definition factory from provided classname.
ComponentDefinitiongetDefinition(String definitionName, ServletRequest request, ServletContext servletContext)
Get a definition by its name.
ComponentDefinitionsFactorygetFactory()
Get underlying factory instance.
voidinitFactory(ServletContext servletContext, Map properties)
Init factory.
voidreload(ServletContext servletContext)
Reload underlying factory.
StringtoString()
Return String representation.

Field Detail

DEFINITIONS_FACTORY_CLASSNAME

public static final String DEFINITIONS_FACTORY_CLASSNAME
Name of init property carrying factory class name.

factory

protected ComponentDefinitionsFactory factory
The real factory instance.

properties

protected Map properties
Initialization parameters.

Constructor Detail

ReloadableDefinitionsFactory

public ReloadableDefinitionsFactory(ServletContext servletContext, ServletConfig servletConfig)
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(ServletContext servletContext, Map properties)
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

createDefaultFactory

public ComponentDefinitionsFactory createDefaultFactory(ServletContext servletContext, Map properties)
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(ServletContext servletContext, Map properties)
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.

createFactoryFromClassname

public ComponentDefinitionsFactory createFactoryFromClassname(ServletContext servletContext, Map properties, String classname)
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

getDefinition

public ComponentDefinition getDefinition(String definitionName, ServletRequest request, ServletContext servletContext)
Get a definition by its name. Call appropriate method on underlying factory instance. Throw appropriate exception if definition or definition factory is not found.

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.

getFactory

public ComponentDefinitionsFactory getFactory()
Get underlying factory instance.

Returns: ComponentDefinitionsFactory

initFactory

public void initFactory(ServletContext servletContext, Map properties)
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.

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.

reload

public void reload(ServletContext servletContext)
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.

toString

public String toString()
Return String representation.

Returns: String representation.

Copyright B) 2000-2009 - The Apache Software Foundation