org.apache.tiles.factory
Class TilesContainerFactory

java.lang.Object
  extended by org.apache.tiles.factory.TilesContainerFactory
Direct Known Subclasses:
KeyedDefinitionsFactoryTilesContainerFactory

public class TilesContainerFactory
extends java.lang.Object

Factory provided for convenience. This factory creates a default implementation of the container, initializes, and puts it into service.

Since:
2.0
Version:
$Rev: 532678 $ $Date: 2007-04-26 11:13:49 +0200 (Thu, 26 Apr 2007) $

Field Summary
static java.lang.String CONTAINER_FACTORY_INIT_PARAM
          Initialization parameter that represents the container factory class name.
static java.lang.String CONTAINER_FACTORY_MUTABLE_INIT_PARAM
          Initialization parameter that indicates if the container factory is mutable.
static java.lang.String CONTEXT_FACTORY_INIT_PARAM
          Initialization parameter that represents the context factory class name.
protected  java.util.Map<java.lang.String,java.lang.String> defaultConfiguration
          The default configuration to be used by the factory.
static java.lang.String DEFINITIONS_FACTORY_INIT_PARAM
          Initialization parameter that represents the definitions factory class name.
static java.lang.String PREPARER_FACTORY_INIT_PARAM
          Initialization parameter that represents the preparer factory class name.
 
Constructor Summary
TilesContainerFactory()
           
 
Method Summary
 TilesContainer createContainer(java.lang.Object context)
          Creates a Tiles container.
protected static java.lang.Object createFactory(java.util.Map<java.lang.String,java.lang.String> configuration, java.lang.String initParameterName)
          Creates a factory instance.
 MutableTilesContainer createMutableTilesContainer(java.lang.Object context)
          Creates a mutable Tiles container.
 TilesContainer createTilesContainer(java.lang.Object context)
          Creates an immutable Tiles container.
static TilesContainerFactory getFactory(java.lang.Object context)
          Retrieve a factory instance as configured through the specified context.
static TilesContainerFactory getFactory(java.lang.Object context, java.util.Map<java.lang.String,java.lang.String> defaults)
          Retrieve a factory instance as configured through the specified context.
protected static java.lang.String getInitParameter(java.lang.Object context, java.lang.String parameterName)
          Returns the value of an initialization parameter.
protected static java.util.Map<java.lang.String,java.lang.String> getInitParameterMap(java.lang.Object context)
          Returns a map containing parameters name-value entries.
protected  void initializeContainer(java.lang.Object context, BasicTilesContainer container)
          Initializes a container.
protected static java.lang.String resolveFactoryName(java.util.Map<java.lang.String,java.lang.String> configuration, java.lang.String parameterName)
          Resolves a factory class name.
 void setDefaultConfiguration(java.util.Map<java.lang.String,java.lang.String> defaultConfiguration)
          Sets the default configuration parameters.
 void setDefaultValue(java.lang.String key, java.lang.String value)
          Sets one default configuration parameter value.
protected  void storeContainerDependencies(java.lang.Object context, java.util.Map<java.lang.String,java.lang.String> initParameters, java.util.Map<java.lang.String,java.lang.String> configuration, BasicTilesContainer container)
          Stores container dependencies, that is called before TilesContainer.init(Map).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTAINER_FACTORY_INIT_PARAM

public static final java.lang.String CONTAINER_FACTORY_INIT_PARAM
Initialization parameter that represents the container factory class name.

See Also:
Constant Field Values

CONTAINER_FACTORY_MUTABLE_INIT_PARAM

public static final java.lang.String CONTAINER_FACTORY_MUTABLE_INIT_PARAM
Initialization parameter that indicates if the container factory is mutable.

See Also:
Constant Field Values

CONTEXT_FACTORY_INIT_PARAM

public static final java.lang.String CONTEXT_FACTORY_INIT_PARAM
Initialization parameter that represents the context factory class name.

See Also:
Constant Field Values

DEFINITIONS_FACTORY_INIT_PARAM

public static final java.lang.String DEFINITIONS_FACTORY_INIT_PARAM
Initialization parameter that represents the definitions factory class name.

See Also:
Constant Field Values

PREPARER_FACTORY_INIT_PARAM

public static final java.lang.String PREPARER_FACTORY_INIT_PARAM
Initialization parameter that represents the preparer factory class name.

See Also:
Constant Field Values

defaultConfiguration

protected java.util.Map<java.lang.String,java.lang.String> defaultConfiguration
The default configuration to be used by the factory.

Constructor Detail

TilesContainerFactory

public TilesContainerFactory()
Method Detail

getFactory

public static TilesContainerFactory getFactory(java.lang.Object context)
                                        throws TilesException
Retrieve a factory instance as configured through the specified context.

The context will be queried and if a init parameter named 'org.apache.tiles.factory.TilesContainerFactory' is discovered this class will be instantiated and returned. Otherwise, the factory will attempt to utilize one of it's internal factories.

Parameters:
context - the executing applications context. Typically a ServletContext or PortletContext
Returns:
a tiles container
Throws:
TilesException - if an error occurs creating the factory.

getFactory

public static TilesContainerFactory getFactory(java.lang.Object context,
                                               java.util.Map<java.lang.String,java.lang.String> defaults)
                                        throws TilesException
Retrieve a factory instance as configured through the specified context.

The context will be queried and if a init parameter named 'org.apache.tiles.factory.TilesContainerFactory' is discovered this class will be instantiated and returned. Otherwise, the factory will attempt to utilize one of it's internal factories.

Parameters:
context - the executing applications context. Typically a ServletContext or PortletContext
defaults - Default configuration parameters values, used if the context object has not the corresponding parameters.
Returns:
a tiles container
Throws:
TilesException - if an error occurs creating the factory.

createContainer

public TilesContainer createContainer(java.lang.Object context)
                               throws TilesException
Creates a Tiles container.

Parameters:
context - The (application) context object.
Returns:
The created container.
Throws:
TilesException - If something goes wrong during instantiation.

setDefaultConfiguration

public void setDefaultConfiguration(java.util.Map<java.lang.String,java.lang.String> defaultConfiguration)
Sets the default configuration parameters.

Parameters:
defaultConfiguration - The default configuration parameters.

setDefaultValue

public void setDefaultValue(java.lang.String key,
                            java.lang.String value)
Sets one default configuration parameter value.

Parameters:
key - The key of the configuration parameter.
value - The value of the configuration parameter.

createTilesContainer

public TilesContainer createTilesContainer(java.lang.Object context)
                                    throws TilesException
Creates an immutable Tiles container.

Parameters:
context - The (application) context object.
Returns:
The created Tiles container.
Throws:
TilesException - If something goes wrong during initialization.

createMutableTilesContainer

public MutableTilesContainer createMutableTilesContainer(java.lang.Object context)
                                                  throws TilesException
Creates a mutable Tiles container.

Parameters:
context - The (application) context object.
Returns:
The created Tiles container.
Throws:
TilesException - If something goes wrong during initialization.

initializeContainer

protected void initializeContainer(java.lang.Object context,
                                   BasicTilesContainer container)
                            throws TilesException
Initializes a container.

Parameters:
context - The (application) context object to use.
container - The container to be initialized.
Throws:
TilesException - If something goes wrong during initialization.

storeContainerDependencies

protected void storeContainerDependencies(java.lang.Object context,
                                          java.util.Map<java.lang.String,java.lang.String> initParameters,
                                          java.util.Map<java.lang.String,java.lang.String> configuration,
                                          BasicTilesContainer container)
                                   throws TilesException
Stores container dependencies, that is called before TilesContainer.init(Map).

Parameters:
context - The (application) context object to use.
initParameters - The initialization parameters.
configuration - The merged configuration parameters (both defaults and context ones).
container - The container to use.
Throws:
TilesException - If something goes wrong during initialization.

createFactory

protected static java.lang.Object createFactory(java.util.Map<java.lang.String,java.lang.String> configuration,
                                                java.lang.String initParameterName)
                                         throws TilesException
Creates a factory instance.

Parameters:
configuration - The merged configuration parameters (both defaults and context ones).
initParameterName - The initialization parameter name from which the class name is got.
Returns:
The created factory.
Throws:
TilesException - If something goes wrong during creation.

resolveFactoryName

protected static java.lang.String resolveFactoryName(java.util.Map<java.lang.String,java.lang.String> configuration,
                                                     java.lang.String parameterName)
                                              throws TilesException
Resolves a factory class name.

Parameters:
configuration - The merged configuration parameters (both defaults and context ones).
parameterName - The name of the initialization parameter to use.
Returns:
The factory class name.
Throws:
TilesException - If something goes wrong during resolution.

getInitParameter

protected static java.lang.String getInitParameter(java.lang.Object context,
                                                   java.lang.String parameterName)
                                            throws TilesException
Returns the value of an initialization parameter.

Parameters:
context - The (application) context object to use.
parameterName - The parameter name to retrieve.
Returns:
The parameter value.
Throws:
TilesException - If the context has not been recognized.

getInitParameterMap

protected static java.util.Map<java.lang.String,java.lang.String> getInitParameterMap(java.lang.Object context)
                                                                               throws TilesException
Returns a map containing parameters name-value entries.

Parameters:
context - The (application) context object to use.
Returns:
The initialization parameters map.
Throws:
TilesException - If the context object has not been recognized.