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

org.apache.tiles.impl.mgmt
Class DefinitionManager

Package class diagram package DefinitionManager
java.lang.Object
  extended by org.apache.tiles.impl.mgmt.DefinitionManager

public class DefinitionManager
extends Object

Manages custom and configured definitions, so they can be used by the container, instead of using a simple DefinitionsFactory.

Version:
$Rev: 616890 $ $Date: 2008-01-30 21:16:51 +0100 (Wed, 30 Jan 2008) $

Constructor Summary
DefinitionManager()
          Constructor.
DefinitionManager(String definitionsAttributeName)
          Constructor.
 
Method Summary
 void addDefinition(Definition definition, TilesRequestContext request)
          Adds a definition to the set of custom ones.
 Definition getDefinition(String definition, TilesRequestContext request)
          Returns a definition by name.
protected  Map<String,Definition> getDefinitions(TilesRequestContext request)
          Returns the map with custom definitions for the current request.
 DefinitionsFactory getFactory()
          Returns the used definitions factory.
protected  Map<String,Definition> getOrCreateDefinitions(TilesRequestContext request)
          Returns a map of type "definition name -> definition" and, if it has not been defined before, creates one.
protected  void overload(Definition parent, Definition child)
          Overloads a child definition with a given parent.
protected  void resolveInheritance(Definition definition, TilesRequestContext request)
          Resolve inheritance.
 void setFactory(DefinitionsFactory factory)
          Sets the definitions factory to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefinitionManager

public DefinitionManager()
Constructor.


DefinitionManager

public DefinitionManager(String definitionsAttributeName)
Constructor.

Parameters:
definitionsAttributeName - The name of the attribute in which storing custom definitions.
Method Detail

getFactory

public DefinitionsFactory getFactory()
Returns the used definitions factory.

Returns:
The used definitions factory.

setFactory

public void setFactory(DefinitionsFactory factory)
Sets the definitions factory to use.

Parameters:
factory - The definitions factory.

getDefinition

public Definition getDefinition(String definition,
                                TilesRequestContext request)
                         throws DefinitionsFactoryException
Returns a definition by name.

Parameters:
definition - The name of the definition.
request - The current request.
Returns:
The requested definition, either main or custom.
Throws:
DefinitionsFactoryException - If something goes wrong when obtaining a main definition.

addDefinition

public void addDefinition(Definition definition,
                          TilesRequestContext request)
                   throws DefinitionsFactoryException
Adds a definition to the set of custom ones.

Parameters:
definition - The definition to add.
request - The current request.
Throws:
DefinitionsFactoryException - If something goes wrong during the addition.

resolveInheritance

protected void resolveInheritance(Definition definition,
                                  TilesRequestContext request)
                           throws DefinitionsFactoryException
Resolve inheritance. First, resolve parent's inheritance, then set template to the parent's template. Also copy attributes setted in parent, and not set in child If instance doesn't extend anything, do nothing.

Parameters:
definition - The definition that needs to have its inheritances resolved.
request - The current request.
Throws:
DefinitionsFactoryException - If an inheritance can not be solved.

overload

protected void overload(Definition parent,
                        Definition child)
Overloads a child definition with a given parent. All attributes present in child are kept. All missing attributes are copied from the parent. Special attribute 'template','role' and 'extends' are overloaded in child if not defined

Parameters:
parent - The parent definition.
child - The child that will be overloaded.

getDefinitions

protected Map<String,Definition> getDefinitions(TilesRequestContext request)
Returns the map with custom definitions for the current request.

Parameters:
request - The current request.
Returns:
A map that connects a definition name to a definition.

getOrCreateDefinitions

protected Map<String,Definition> getOrCreateDefinitions(TilesRequestContext request)
Returns a map of type "definition name -> definition" and, if it has not been defined before, creates one.

Parameters:
request - The current request.
Returns:
A map that connects a definition name to a definition.


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