org.apache.shale.clay.config.beans
Class TemplateConfigBean

java.lang.Object
  extended by org.apache.shale.clay.config.beans.ComponentConfigBean
      extended by org.apache.shale.clay.config.beans.TemplateConfigBean
All Implemented Interfaces:
Comparable, ConfigBean
Direct Known Subclasses:
TemplateComponentConfigBean

public class TemplateConfigBean
extends ComponentConfigBean

The second type of top-level object pool. This implementation is designed to provide Tapestry like template composition. The top-level ComponentBean is materialized from a HTML fragment where HTML elements are bound to meta components defined in the XML configuration files and cached by an instance of ComponentConfigBean


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.shale.clay.config.beans.ComponentConfigBean
ComponentConfigBean.WatchDog, ComponentConfigBean.XmlConfigDef
 
Nested classes/interfaces inherited from interface org.apache.shale.clay.config.beans.ConfigBean
ConfigBean.ConfigDefinition
 
Field Summary
 
Fields inherited from class org.apache.shale.clay.config.beans.ComponentConfigBean
context, displayElements, isWatchDogOn, messages, NAMING_CONTAINER_TYPES, parser, suffixes, watchDogs
 
Constructor Summary
TemplateConfigBean()
           
 
Method Summary
protected  void clear(String watchDogName)
          If the watchDogName equals the ComponentBean that defines the selected template, remove it.
 ComponentBean getElement(String templateName)
          Returns a ComponentBean that is materialized using a HTML template fragment.
protected  ComponentBean getTopLevelElement(String jsfid)
           Returns the root metadata component that is used to add to the component tree.
 int getWeight()
          Returns an integer value use to order the registered ConfigBean instances with the ConfigBeanFactory.
 void init(ServletContext context)
          The HTML templates are loaded on-demand.
protected  void loadConfigFiles()
          This is an overridden method called from the init method.
 void optimizeTree(ComponentBean root)
          Recursively walks down the graph of meta-data ComponentBean's looking at the children of the root.
 boolean refresh(boolean forceReload)
          If the forceReload is true, the displayElements cache is invalidated.
 boolean validMoniker(String id)
          Overrides the super call to change the condition of the filter.
 
Methods inherited from class org.apache.shale.clay.config.beans.ComponentConfigBean
addChild, assignParent, checkCircularInheritance, checkTree, checkTree, compareTo, describeRelationships, destroy, getAssociations, getConfigDefinitions, getGeneralizations, getServletContext, isDesigntime, isNamingContainer, realizingInheritance, realizingInheritance, resolveInheritance, setDesigntime, unassignParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateConfigBean

public TemplateConfigBean()
Method Detail

getElement

public ComponentBean getElement(String templateName)

Returns a ComponentBean that is materialized using a HTML template fragment. The templateName is the name of the file relative to the context root of the web application

Specified by:
getElement in interface ConfigBean
Overrides:
getElement in class ComponentConfigBean
Parameters:
templateName - name of the markup template
Returns:
root component bean for the templateName

getWeight

public int getWeight()

Returns an integer value use to order the registered ConfigBean instances with the ConfigBeanFactory.

Specified by:
getWeight in interface ConfigBean
Overrides:
getWeight in class ComponentConfigBean
Returns:
weight value of 1

validMoniker

public boolean validMoniker(String id)

Overrides the super call to change the condition of the filter. This ConfigBean can create components where the id end in the suffix defined in the web deployment descriptor as a initialization parameter with the name defined by Globals.CLAY_HTML_TEMPLATE_SUFFIX Or, using the default defined by Globals.CLAY_DEFAULT_HTML_TEMPLATE_SUFFIX

Specified by:
validMoniker in interface ConfigBean
Overrides:
validMoniker in class ComponentConfigBean
Parameters:
id - jsfid
Returns:
true if the jsfid can be handled here

loadConfigFiles

protected void loadConfigFiles()

This is an overridden method called from the init method. It loads an instance of the ClayTemplateParser and establishes a Map collection to hold the resource ComponentConfigBean.WatchDog's.

Overrides:
loadConfigFiles in class ComponentConfigBean

init

public void init(ServletContext context)

The HTML templates are loaded on-demand. Override this method forcing the auto load option on. The XML configuration files are only effected by the auto-reload-clay-files initialization parameter.

Specified by:
init in interface ConfigBean
Overrides:
init in class ComponentConfigBean
Parameters:
context - web container servlet context

clear

protected void clear(String watchDogName)

If the watchDogName equals the ComponentBean that defines the selected template, remove it.

Overrides:
clear in class ComponentConfigBean
Parameters:
watchDogName - grouping of template files

refresh

public boolean refresh(boolean forceReload)

If the forceReload is true, the displayElements cache is invalidated. A true value is returned if cache has been cleared.

Specified by:
refresh in interface ConfigBean
Overrides:
refresh in class ComponentConfigBean
Parameters:
forceReload - invalidate the cache flag
Returns:
true if the templates were reloaded

getTopLevelElement

protected ComponentBean getTopLevelElement(String jsfid)

Returns the root metadata component that is used to add to the component tree. It locates the ComponentBean using the jsfid attribute as the key. A call to the ConfigBeanFactory locates the correct ConfigBean used to find the ComponentBean.

Overrides:
getTopLevelElement in class ComponentConfigBean
Parameters:
jsfid - parent id of a config bean
Returns:
parent config bean

optimizeTree

public void optimizeTree(ComponentBean root)

Recursively walks down the graph of meta-data ComponentBean's looking at the children of the root. Adjacent children that are both verbatim component definitions are merged. If there is only one child and the child and root nodes are both verbatim definitions, the child is merged up to the root.

Parameters:
root - top config bean that represents a markup template


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.