Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tiles.impl
Class BasicTilesContainer

    java.lang.Object
      org.apache.tiles.impl.BasicTilesContainer

All Implemented Interfaces:
  AttributeEvaluatorFactoryAware, TilesContainer

Direct Known Subclasses:
  CachingTilesContainer, KeyedDefinitionsFactoryTilesContainer

    public class BasicTilesContainer

extends java.lang.Object
implements TilesContainer, AttributeEvaluatorFactoryAware

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
Version:
  $Rev: 797765 $ $Date: 2009-07-25 15:20:26 +0200 (sab, 25 lug 2009) $

Field Summary
`static java.lang.String` | `DEFINITIONS_CONFIG` Deprecated. Use `DefinitionsFactory.DEFINITIONS_CONFIG`.

Constructor Summary
`BasicTilesContainer()`

Method Summary
`protected void` | `checkInit()` Determine whether or not the container has been initialized.
`void` | `endContext(java.lang.Object... requestItems)` Ends a context, where attribute values are stored independently from others.
`java.lang.Object` | `evaluate(Attribute attribute, java.lang.Object... requestItems)` Evaluates the given attribute.
`TilesApplicationContext` | `getApplicationContext()` Returns the Tiles application context used by this container.
`AttributeContext` | `getAttributeContext(java.lang.Object... requestItems)` Retrive the attribute context of the current request.
`protected AttributeContext` | `getContext(TilesRequestContext tilesContext)` Get attribute context from request.
`TilesContextFactory` | `getContextFactory()` Deprecated. Do not use it, it returns `null`. Use `getRequestContextFactory()`.
`protected ArrayStack<AttributeContext>` | `getContextStack(TilesRequestContext tilesContext)` Returns the context stack.
`protected 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 TilesRequestContextFactory` | `getRequestContextFactory()` Returns the request context factory.
`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)` Deprecated. Do not use, the Definitions Factory should be initialized by the Tiles Container Factory.
`boolean` | `isValidDefinition(java.lang.String definitionName, java.lang.Object... requestItems)` Determine whether or not the definition exists.
`protected AttributeContext` | `popContext(TilesRequestContext tilesContext)` Pops a context object out of the stack.
`void` | `prepare(java.lang.String preparer, java.lang.Object... requestItems)` Executes a preparer.
`protected void` | `pushContext(AttributeContext context, TilesRequestContext tilesContext)` Pushes a context object in the stack.
`void` | `render(Attribute attr, java.lang.Object... requestItems)` Render the given Attribute.
`void` | `render(Attribute attr, java.io.Writer writer, java.lang.Object... requestItems)` Deprecated.
`void` | `render(java.lang.String definitionName, java.lang.Object... requestItems)` Render the given tiles request.
`protected void` | `render(TilesRequestContext request, AttributeContext attributeContext)` Renders the specified attribute context.
`protected void` | `render(TilesRequestContext request, Definition definition)` Renders the specified definition.
`protected void` | `render(TilesRequestContext request, java.lang.String definitionName)` Renders the definition with specified name.
`void` | `renderContext(java.lang.Object... requestItems)` Renders the current context, as it is.
`void` | `setApplicationContext(TilesApplicationContext context)` Sets the Tiles application context to use.
`void` | `setAttributeEvaluatorFactory(AttributeEvaluatorFactory attributeEvaluatorFactory)` Sets the attribute evaluator factory.
`void` | `setContextFactory(TilesContextFactory contextFactory)` Deprecated. Use `setRequestContextFactory(TilesRequestContextFactory)`.
`void` | `setDefinitionsFactory(DefinitionsFactory definitionsFactory)` Set the definitions factory.
`void` | `setPreparerFactory(PreparerFactory preparerFactory)` Set the preparerInstance factory.
`void` | `setRendererFactory(RendererFactory rendererFactory)` Sets the renderer instance factory.
`void` | `setRequestContextFactory(TilesRequestContextFactory contextFactory)` Sets the request context factory.
`AttributeContext` | `startContext(java.lang.Object... requestItems)` Starts a new context, where attribute values are stored independently from others.

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

  Deprecated. Use `DefinitionsFactory.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)

  Initialize the Container with the given configuration.

  Specified by:
    `init` in interface `TilesContainer`
  Parameters:
    `initParameters` - application context for this container
  Throws:
    `java.lang.IllegalStateException` - If the container has been already initialized.
    `DefinitionsFactoryException` - If something goes wrong during initialization.

### startContext

    public AttributeContext startContext(java.lang.Object... requestItems)

  Starts a new context, where attribute values are stored independently from others.
  When the use of the contexts is finished, call `TilesContainer.endContext(Object...)`

  Specified by:
    `startContext` in interface `TilesContainer`
  Parameters:
    `requestItems` - the current request objects.
  Returns:
    The newly created context.

### endContext

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

  Ends a context, where attribute values are stored independently from others.
  It must be called after a `TilesContainer.startContext(Object...)` call.

  Specified by:
    `endContext` in interface `TilesContainer`
  Parameters:
    `requestItems` - the current request objects.

### renderContext

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

  Renders the current context, as it is.

  Specified by:
    `renderContext` in interface `TilesContainer`
  Parameters:
    `requestItems` - the current request objects.

### getApplicationContext

    public TilesApplicationContext getApplicationContext()

  Returns the Tiles application context used by this container.

  Specified by:
    `getApplicationContext` in interface `TilesContainer`
  Returns:
    the application context for this container.

### setApplicationContext

    public void setApplicationContext(TilesApplicationContext context)

  Sets the Tiles application context to use.

  Parameters:
    `context` - The Tiles application context.

### getAttributeContext

    public AttributeContext getAttributeContext(java.lang.Object... requestItems)

  Retrive the attribute context of the current request.

  Specified by:
    `getAttributeContext` in interface `TilesContainer`
  Parameters:
    `requestItems` - the current request objects.
  Returns:
    map of the attributes in the current attribute context.

### getContextFactory

    @Deprecated
    public TilesContextFactory getContextFactory()

  Deprecated. Do not use it, it returns `null`. Use `getRequestContextFactory()`.

  Returns the context factory.

  Returns:
    Always `null`.

### getRequestContextFactory

    protected TilesRequestContextFactory getRequestContextFactory()

  Returns the request context factory.

  Returns:
    The request context factory.
  Since:
    2.1.1

### setContextFactory

    public void setContextFactory(TilesContextFactory contextFactory)

  Deprecated. Use `setRequestContextFactory(TilesRequestContextFactory)`.

  Sets the context factory.

  Parameters:
    `contextFactory` - The context factory.

### setRequestContextFactory

    public void setRequestContextFactory(TilesRequestContextFactory contextFactory)

  Sets the request context factory.

  Parameters:
    `contextFactory` - The context factory.
  Since:
    2.1.1

### 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.

### setRendererFactory

    public void setRendererFactory(RendererFactory rendererFactory)

  Sets the renderer instance factory.

  Parameters:
    `rendererFactory` - the renderer instance factory for this container.
  Since:
    2.1.0

### setAttributeEvaluatorFactory

    public void setAttributeEvaluatorFactory(AttributeEvaluatorFactory attributeEvaluatorFactory)

  Sets the attribute evaluator factory.

  Specified by:
    `setAttributeEvaluatorFactory` in interface `AttributeEvaluatorFactoryAware`
  Parameters:
    `attributeEvaluatorFactory` - The attribute evaluator factory to use.

### prepare

    public void prepare(java.lang.String preparer,
                        java.lang.Object... requestItems)

  Executes a preparer.

  Specified by:
    `prepare` in interface `TilesContainer`
  Parameters:
    `preparer` - The name of the preparer to execute.
    `requestItems` - the current request objects.

### render

    public void render(java.lang.String definitionName,
                       java.lang.Object... requestItems)

  Render the given tiles request.

  Specified by:
    `render` in interface `TilesContainer`
  Parameters:
    `definitionName` - the current definition.
    `requestItems` - the current request objects.

### render

    @Deprecated
    public void render(Attribute attr,
                                  java.io.Writer writer,
                                  java.lang.Object... requestItems)
                throws java.io.IOException

  Deprecated.

  Render the given Attribute.

  Specified by:
    `render` in interface `TilesContainer`
  Parameters:
    `attr` - The attribute to render.
    `writer` - A writer. IT WON'T BE EVALUATED!!!
    `requestItems` - the current request objects.
  Throws:
    `java.io.IOException` - If something goes wrong during writing to the output.

### render

    public void render(Attribute attr,
                       java.lang.Object... requestItems)
                throws java.io.IOException

  Render the given Attribute.

  Specified by:
    `render` in interface `TilesContainer`
  Parameters:
    `attr` - The attribute to render.
    `requestItems` - the current request objects.
  Throws:
    `java.io.IOException` - If something goes wrong during writing to the output.

### evaluate

    public java.lang.Object evaluate(Attribute attribute,
                                     java.lang.Object... requestItems)

  Evaluates the given attribute.

  Specified by:
    `evaluate` in interface `TilesContainer`
  Parameters:
    `attribute` - The attribute to evaluate.
    `requestItems` - the current request objects.
  Returns:
    The evaluated object.

### isValidDefinition

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

  Determine whether or not the definition exists.

  Specified by:
    `isValidDefinition` in interface `TilesContainer`
  Parameters:
    `definitionName` - the name of the definition.
    `requestItems` - the current request objects.
  Returns:
    true if the definition is found.

### getDefinition

    protected Definition getDefinition(java.lang.String definitionName,
                                       TilesRequestContext request)

  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

### 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

    @Deprecated
    protected void initializeDefinitionsFactory(DefinitionsFactory definitionsFactory,
                                                           java.lang.String resourceString,
                                                           java.util.Map<java.lang.String,java.lang.String> initParameters)

  Deprecated. Do not use, the Definitions Factory should be initialized by the Tiles Container Factory.

  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:
    `DefinitionsFactoryException` - If something goes wrong.

### getContextStack

    protected ArrayStack<AttributeContext> getContextStack(TilesRequestContext tilesContext)

  Returns the context stack.

  Parameters:
    `tilesContext` - The Tiles context object to use.
  Returns:
    The needed stack of contexts.
  Since:
    2.0.6

### pushContext

    protected void pushContext(AttributeContext context,
                               TilesRequestContext tilesContext)

  Pushes a context object in the stack.

  Parameters:
    `context` - The context to push.
    `tilesContext` - The Tiles context object to use.
  Since:
    2.0.6

### popContext

    protected AttributeContext popContext(TilesRequestContext tilesContext)

  Pops a context object out of the stack.

  Parameters:
    `tilesContext` - The Tiles context object to use.
  Returns:
    The popped context object.
  Since:
    2.0.6

### getContext

    protected AttributeContext getContext(TilesRequestContext tilesContext)

  Get attribute context from request.

  Parameters:
    `tilesContext` - current Tiles application context.
  Returns:
    BasicAttributeContext or null if context is not found.
  Since:
    2.0.6

### render

    protected void render(TilesRequestContext request,
                          java.lang.String definitionName)

  Renders the definition with specified name.

  Parameters:
    `request` - The request context.
    `definitionName` - The name of the definition to render.
  Throws:
    `NoSuchDefinitionException` - If the definition has not been found.
    `DefinitionsFactoryException` - If something goes wrong when obtaining the definition.
  Since:
    2.1.3

### render

    protected void render(TilesRequestContext request,
                          Definition definition)

  Renders the specified definition.

  Parameters:
    `request` - The request context.
    `definition` - The definition to render.
  Since:
    2.1.3

### render

    protected void render(TilesRequestContext request,
                          AttributeContext attributeContext)

  Renders the specified attribute context.

  Parameters:
    `request` - The request context.
    `attributeContext` - The context to render.
  Throws:
    `InvalidTemplateException` - If the template is not valid.
    `CannotRenderException` - If something goes wrong during rendering.
  Since:
    2.1.3

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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