org.apache.struts.tiles.definition
Class ComponentDefinitionsFactoryWrapper

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

public class ComponentDefinitionsFactoryWrapper
extends java.lang.Object
implements DefinitionsFactory

Wrapper from new definition factory interface to old interface. This class provides mapping from the old interface's life cycle to the new life cycle.

Since:
20020708
Author:
Cedric Dumoulin
See Also:
Serialized Form

Field Summary
private  DefinitionsFactoryConfig config
          Factory configuration
private  ComponentDefinitionsFactory factory
          The underlying factory
 
Constructor Summary
ComponentDefinitionsFactoryWrapper()
          Constructor.
ComponentDefinitionsFactoryWrapper(ComponentDefinitionsFactory factory)
          Constructor.
 
Method Summary
static java.util.Map createConfigMap(DefinitionsFactoryConfig config)
          Create map of configuration attributes from configuration object.
protected  ComponentDefinitionsFactory createFactoryInstance(java.lang.String classname)
          Create Definition factory from provided classname which must implements ComponentDefinitionsFactory.
 void destroy()
          Do nothing because old life cycle has no equivalent.
 DefinitionsFactoryConfig getConfig()
          Get underlying factory configuration.
 ComponentDefinition getDefinition(java.lang.String name, javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)
          Get requested definition.
 ComponentDefinitionsFactory getInternalFactory()
          Get internal factory
 void init(DefinitionsFactoryConfig config, javax.servlet.ServletContext servletContext)
          Call underlying factory init method.
 void setConfig(DefinitionsFactoryConfig config, javax.servlet.ServletContext servletContext)
          Set underlying factory configuration.
 java.lang.String toString()
          ToString method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

factory

private ComponentDefinitionsFactory factory
The underlying factory


config

private DefinitionsFactoryConfig config
Factory configuration

Constructor Detail

ComponentDefinitionsFactoryWrapper

public ComponentDefinitionsFactoryWrapper(ComponentDefinitionsFactory factory)
Constructor. Create new wrapper for specified factory.


ComponentDefinitionsFactoryWrapper

public ComponentDefinitionsFactoryWrapper()
Constructor. Create new wrapper. The config object passed to init method should reference a factory implementing ComponentDefinitionsFactory.

Method Detail

getDefinition

public ComponentDefinition getDefinition(java.lang.String name,
                                         javax.servlet.ServletRequest request,
                                         javax.servlet.ServletContext servletContext)
                                  throws NoSuchDefinitionException,
                                         DefinitionsFactoryException
Get requested definition.

Specified by:
getDefinition in interface DefinitionsFactory
Parameters:
name - Name of requested definition.
request - Current servelet request
servletContext - current servlet context
Throws:
NoSuchDefinitionException - No definition found for specified name Implementation can throw more accurate exception as a subclass of this exception
DefinitionsFactoryException - An error occur while getting definition.

init

public void init(DefinitionsFactoryConfig config,
                 javax.servlet.ServletContext servletContext)
          throws DefinitionsFactoryException
Call underlying factory init method.

Specified by:
init in interface DefinitionsFactory
Parameters:
config - Configuration object used to set factory configuration.
servletContext - Servlet Context passed to factory.
Throws:
DefinitionsFactoryException - An error occur during initialization.

destroy

public void destroy()
Do nothing because old life cycle has no equivalent.

Specified by:
destroy in interface DefinitionsFactory

setConfig

public void setConfig(DefinitionsFactoryConfig config,
                      javax.servlet.ServletContext servletContext)
               throws DefinitionsFactoryException
Set underlying factory configuration.

Specified by:
setConfig in interface DefinitionsFactory
Parameters:
config - Configuration object used to set factory configuration.
servletContext - Servlet Context passed to factory.
Throws:
DefinitionsFactoryException - An error occur during initialization.

getConfig

public DefinitionsFactoryConfig getConfig()
Get underlying factory configuration.

Specified by:
getConfig in interface DefinitionsFactory
Returns:
TilesConfig

getInternalFactory

public ComponentDefinitionsFactory getInternalFactory()
Get internal factory


createFactoryInstance

protected ComponentDefinitionsFactory createFactoryInstance(java.lang.String classname)
                                                     throws DefinitionsFactoryException
Create Definition factory from provided classname which must implements ComponentDefinitionsFactory. Factory class must extends TilesDefinitionsFactory.

Parameters:
classname - Class name of the factory to create.
Returns:
newly created factory.
Throws:
DefinitionsFactoryException - If an error occur while initializing factory

toString

public java.lang.String toString()
ToString method. Call toString on underlying factory.

Overrides:
toString in class java.lang.Object

createConfigMap

public static java.util.Map createConfigMap(DefinitionsFactoryConfig config)
Create map of configuration attributes from configuration object. Mapping is done between old names and new names.

Returns:
Map Map of name/value pairs.


Copyright 2000-2002 - Cedric Dumoulin and Apache Software Foundation