Class ReloadableDefinitionsFactory

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

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$ $Date$
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • createFactoryFromClassname

      public ComponentDefinitionsFactory createFactoryFromClassname(ServletContext servletContext, Map<String,Object> properties, 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:
      servletContext - Servlet Context passed to newly created factory.
      properties - Map of name/property passed to newly created factory.
      classname - Class name of the factory to create.
      Returns:
      newly created factory.
      Throws:
      DefinitionsFactoryException - If an error occur while initializing factory
    • createDefaultFactory

      public ComponentDefinitionsFactory createDefaultFactory(ServletContext servletContext, Map<String,Object> 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(ServletContext servletContext, Map<String,Object> 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.
      Throws:
      DefinitionsFactoryException
    • getDefinition

      public ComponentDefinition getDefinition(String definitionName, ServletRequest request, 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(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(ServletContext servletContext, Map<String,Object> 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 String toString()
      Return String representation.
      Overrides:
      toString in class Object
      Returns:
      String representation.