org.apache.tiles.impl
Class BasicTilesContainer

Package class diagram package BasicTilesContainer
java.lang.Object
  extended by org.apache.tiles.impl.BasicTilesContainer
All Implemented Interfaces:
org.apache.tiles.TilesContainer
Direct Known Subclasses:
CachingTilesContainer, KeyedDefinitionsFactoryTilesContainer

public class BasicTilesContainer
extends java.lang.Object
implements org.apache.tiles.TilesContainer

Basic implementation of the tiles container interface. In most cases, this container will be customized by injecting customized services, not necessarily by override the container

Since:
2.0

Field Summary
static java.lang.String DEFINITIONS_CONFIG
          Constant representing the configuration parameter used to define the tiles definition resources.
 
Constructor Summary
BasicTilesContainer()
           
 
Method Summary
protected  void checkInit()
          Determine whether or not the container has been initialized.
 void endContext(java.lang.Object... requestItems)
          
 org.apache.tiles.TilesApplicationContext getApplicationContext()
          Returns the Tiles application context used by this container.
 org.apache.tiles.AttributeContext getAttributeContext(java.lang.Object... requestItems)
          
 TilesContextFactory getContextFactory()
          Returns the context factory.
protected  org.apache.tiles.Definition getDefinition(java.lang.String definitionName, TilesRequestContext request)
          Returns a definition specifying its name.
 DefinitionsFactory getDefinitionsFactory()
          Returns the definitions factory.
 PreparerFactory getPreparerFactory()
          Returns the preparer factory used by this container.
protected  java.util.List<java.lang.String> getResourceNames(java.lang.String resourceString)
          Parse the resourceString into a list of resource paths which can be loaded by the application context.
protected  java.lang.String getResourceString()
          Derive the resource string from the initialization parameters.
protected  java.lang.String getResourceString(java.util.Map<java.lang.String,java.lang.String> parms)
          Derive the resource string from the initialization parameters.
 void init(java.util.Map<java.lang.String,java.lang.String> initParameters)
          Initialize the Container with the given configuration.
protected  void initializeDefinitionsFactory(DefinitionsFactory definitionsFactory, java.lang.String resourceString, java.util.Map<java.lang.String,java.lang.String> initParameters)
          Initializes a definitions factory.
 boolean isValidDefinition(java.lang.String definitionName, java.lang.Object... requestItems)
          
 void prepare(java.lang.String preparer, java.lang.Object... requestItems)
          
 void render(org.apache.tiles.Attribute attr, java.io.Writer writer, java.lang.Object... requestItems)
          
 void render(java.lang.String definitionName, java.lang.Object... requestItems)
          
 void setApplicationContext(org.apache.tiles.TilesApplicationContext context)
          Sets the Tiles application context to use.
 void setContextFactory(TilesContextFactory contextFactory)
          Sets the context factory.
 void setDefinitionsFactory(DefinitionsFactory definitionsFactory)
          Set the definitions factory.
 void setPreparerFactory(PreparerFactory preparerFactory)
          Set the preparerInstance factory.
 org.apache.tiles.AttributeContext startContext(java.lang.Object... requestItems)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFINITIONS_CONFIG

public static final java.lang.String DEFINITIONS_CONFIG
Constant representing the configuration parameter used to define the tiles definition resources.

See Also:
Constant Field Values
Constructor Detail

BasicTilesContainer

public BasicTilesContainer()
Method Detail

init

public void init(java.util.Map<java.lang.String,java.lang.String> initParameters)
          throws org.apache.tiles.TilesException
Initialize the Container with the given configuration.

Specified by:
init in interface org.apache.tiles.TilesContainer
Parameters:
initParameters - application context for this container
Throws:
org.apache.tiles.TilesException - If something goes wrong during initialization.

startContext

public org.apache.tiles.AttributeContext startContext(java.lang.Object... requestItems)

Specified by:
startContext in interface org.apache.tiles.TilesContainer

endContext

public void endContext(java.lang.Object... requestItems)

Specified by:
endContext in interface org.apache.tiles.TilesContainer

checkInit

protected void checkInit()
Determine whether or not the container has been initialized. Utility method used for methods which can not be invoked after the container has been started.

Throws:
java.lang.IllegalStateException - if the container has already been initialized.

initializeDefinitionsFactory

protected void initializeDefinitionsFactory(DefinitionsFactory definitionsFactory,
                                            java.lang.String resourceString,
                                            java.util.Map<java.lang.String,java.lang.String> initParameters)
                                     throws org.apache.tiles.TilesException
Initializes a definitions factory.

Parameters:
definitionsFactory - The factory to initialize.
resourceString - The string containing a comma-separated-list of resources.
initParameters - A map containing the initialization parameters.
Throws:
org.apache.tiles.TilesException - If something goes wrong.

getApplicationContext

public org.apache.tiles.TilesApplicationContext getApplicationContext()
Returns the Tiles application context used by this container.

Specified by:
getApplicationContext in interface org.apache.tiles.TilesContainer
Returns:
the application context for this container.

setApplicationContext

public void setApplicationContext(org.apache.tiles.TilesApplicationContext context)
Sets the Tiles application context to use.

Parameters:
context - The Tiles application context.

getAttributeContext

public org.apache.tiles.AttributeContext getAttributeContext(java.lang.Object... requestItems)

Specified by:
getAttributeContext in interface org.apache.tiles.TilesContainer

getContextFactory

public TilesContextFactory getContextFactory()
Returns the context factory.

Returns:
The context factory.

setContextFactory

public void setContextFactory(TilesContextFactory contextFactory)
Sets the context factory.

Parameters:
contextFactory - The context factory.

getDefinitionsFactory

public DefinitionsFactory getDefinitionsFactory()
Returns the definitions factory.

Returns:
The definitions factory used by this container.

setDefinitionsFactory

public void setDefinitionsFactory(DefinitionsFactory definitionsFactory)
Set the definitions factory. This method first ensures that the container has not yet been initialized.

Parameters:
definitionsFactory - the definitions factory for this instance.

getPreparerFactory

public PreparerFactory getPreparerFactory()
Returns the preparer factory used by this container.

Returns:
return the preparerInstance factory used by this container.

setPreparerFactory

public void setPreparerFactory(PreparerFactory preparerFactory)
Set the preparerInstance factory. This method first ensures that the container has not yet been initialized.

Parameters:
preparerFactory - the preparerInstance factory for this conainer.

prepare

public void prepare(java.lang.String preparer,
                    java.lang.Object... requestItems)
             throws org.apache.tiles.TilesException

Specified by:
prepare in interface org.apache.tiles.TilesContainer
Throws:
org.apache.tiles.TilesException

render

public void render(java.lang.String definitionName,
                   java.lang.Object... requestItems)
            throws org.apache.tiles.TilesException

Specified by:
render in interface org.apache.tiles.TilesContainer
Throws:
org.apache.tiles.TilesException

render

public void render(org.apache.tiles.Attribute attr,
                   java.io.Writer writer,
                   java.lang.Object... requestItems)
            throws org.apache.tiles.TilesException,
                   java.io.IOException

Specified by:
render in interface org.apache.tiles.TilesContainer
Throws:
org.apache.tiles.TilesException
java.io.IOException

getDefinition

protected org.apache.tiles.Definition getDefinition(java.lang.String definitionName,
                                                    TilesRequestContext request)
                                             throws DefinitionsFactoryException
Returns a definition specifying its name.

Parameters:
definitionName - The name of the definition to find.
request - The request context.
Returns:
The definition, if found.
Throws:
DefinitionsFactoryException - If the definitions factory throws an exception.

getResourceString

protected java.lang.String getResourceString()
Derive the resource string from the initialization parameters. If no parameter DEFINITIONS_CONFIG is available, attempts to retrieve LEGACY_DEFINITIONS_CONFIG. If niether are available, returns "/WEB-INF/tiles.xml".

Returns:
resource string to be parsed.

getResourceString

protected java.lang.String getResourceString(java.util.Map<java.lang.String,java.lang.String> parms)
Derive the resource string from the initialization parameters. If no parameter DEFINITIONS_CONFIG is available, attempts to retrieve LEGACY_DEFINITIONS_CONFIG. If niether are available, returns "/WEB-INF/tiles.xml".

Parameters:
parms - The initialization parameters.
Returns:
resource string to be parsed.

getResourceNames

protected java.util.List<java.lang.String> getResourceNames(java.lang.String resourceString)
Parse the resourceString into a list of resource paths which can be loaded by the application context.

Parameters:
resourceString - comma seperated resources
Returns:
parsed resources

isValidDefinition

public boolean isValidDefinition(java.lang.String definitionName,
                                 java.lang.Object... requestItems)

Specified by:
isValidDefinition in interface org.apache.tiles.TilesContainer