This project has retired. For details please refer to its Attic page.
TilesContainerFactory (Tiles 2 2.0.7 API)

org.apache.tiles.factory
Class TilesContainerFactory

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

public class TilesContainerFactory
extends 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: 680124 $ $Date: 2008-07-27 17:20:00 +0200 (Sun, 27 Jul 2008) $

Field Summary
static String CONTAINER_FACTORY_INIT_PARAM
          Initialization parameter that represents the container factory class name.
static String CONTAINER_FACTORY_MUTABLE_INIT_PARAM
          Initialization parameter that indicates if the container factory is mutable.
static String CONTEXT_FACTORY_INIT_PARAM
          Initialization parameter that represents the context factory class name.
protected  Map<String,String> defaultConfiguration
          The default configuration to be used by the factory.
static String DEFINITIONS_FACTORY_INIT_PARAM
          Initialization parameter that represents the definitions factory class name.
static String PREPARER_FACTORY_INIT_PARAM
          Initialization parameter that represents the preparer factory class name.
 
Constructor Summary
TilesContainerFactory()
           
 
Method Summary
 TilesContainer createContainer(Object context)
          Creates a Tiles container.
protected static Object createFactory(Map<String,String> configuration, String initParameterName)
          Creates a factory instance.
 MutableTilesContainer createMutableTilesContainer(Object context)
          Creates a mutable Tiles container.
 TilesContainer createTilesContainer(Object context)
          Creates an immutable Tiles container.
static TilesContainerFactory getFactory(Object context)
          Retrieve a factory instance as configured through the specified context.
static TilesContainerFactory getFactory(Object context, Map<String,String> defaults)
          Retrieve a factory instance as configured through the specified context.
protected static String getInitParameter(Object context, String parameterName)
          Returns the value of an initialization parameter.
protected static Map<String,String> getInitParameterMap(Object context)
          Returns a map containing parameters name-value entries.
protected  void initializeContainer(Object context, BasicTilesContainer container)
          Initializes a container.
protected static String resolveFactoryName(Map<String,String> configuration, String parameterName)
          Resolves a factory class name.
 void setDefaultConfiguration(Map<String,String> defaultConfiguration)
          Sets the default configuration parameters.
 void setDefaultValue(String key, String value)
          Sets one default configuration parameter value.
protected  void storeContainerDependencies(Object context, Map<String,String> initParameters, Map<String,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 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 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 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 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 String PREPARER_FACTORY_INIT_PARAM
Initialization parameter that represents the preparer factory class name.

See Also:
Constant Field Values

defaultConfiguration

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

Constructor Detail

TilesContainerFactory

public TilesContainerFactory()
Method Detail

getFactory

public static TilesContainerFactory getFactory(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(Object context,
                                               Map<String,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(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(Map<String,String> defaultConfiguration)
Sets the default configuration parameters.

Parameters:
defaultConfiguration - The default configuration parameters.

setDefaultValue

public void setDefaultValue(String key,
                            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(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(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(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(Object context,
                                          Map<String,String> initParameters,
                                          Map<String,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 Object createFactory(Map<String,String> configuration,
                                      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 String resolveFactoryName(Map<String,String> configuration,
                                           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 String getInitParameter(Object context,
                                         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 Map<String,String> getInitParameterMap(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.


Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.