public class ComponentConfigBean extends Object implements ConfigBean
This class is kind of the metadata object pool for configuration data
loaded from XML files on startup in the ClayConfigureListener
by the ClayXmlParser
. An instance of this
class will be registered with the ConfigBeanFactory
.
Modifier and Type | Class and Description |
---|---|
protected class |
ComponentConfigBean.WatchDog
This inner class watches for changes in a array of
ConfigBean.ConfigDefinition 's. |
protected class |
ComponentConfigBean.XmlConfigDef
This class defines a single configration file that is watched for
changes.
|
ConfigBean.ConfigDefinition
Modifier and Type | Field and Description |
---|---|
protected javax.servlet.ServletContext |
context
Reference to the
ServletContext . |
protected Map |
displayElements
Collection holding all the top-level components defined in the XML
config files.
|
protected boolean |
isWatchDogOn
This parameter is initialized from the
init
method from the org.apache.shale.clay.AUTO_RELOAD_CONFIG_FILES init
parameter in the web.xml. |
protected static Messages |
messages
Message resources for this class.
|
protected static String[] |
NAMING_CONTAINER_TYPES
A static string array of faces component types that are naming
containers.
|
protected ClayConfigParser |
parser
Uses the digester to load the configuration files
into a object graph cached in
displayElements . |
protected String[] |
suffixes
The suffixes used to identify that a jsfid is a template style of
composition.
|
protected Map |
watchDogs
Map of
ComponentConfigBean.WatchDog that watches the configuration files looking for changes. |
Constructor and Description |
---|
ComponentConfigBean()
Constructor initializes the
displayElements
collection. |
Modifier and Type | Method and Description |
---|---|
void |
addChild(ComponentBean obj)
Adds a {link ComponentBean} to the
displayElement map collection using
the jsfid as the key. |
void |
assignParent(ComponentBean b)
Called to assign the IsA parent to the
ComponentBean
using the extends attribute. |
protected void |
checkCircularInheritance(ComponentBean b)
Passed a
ComponentBean , the method looks for several
types of circular inheritances. |
void |
checkTree(ComponentBean b)
Recursively walks the tree of component metadata verifying
there is not a duplicate component id within a naming container.
|
protected void |
checkTree(List componentIds,
ComponentBean b)
Verifies there is not a duplicate component id within a naming container.
|
protected void |
clear(String watchDogName)
Cleans up before a group of files are reloaded.
|
int |
compareTo(Object config)
Implementation of the Comparable interface.
|
protected StringBuffer |
describeRelationships(Stack heritage)
Returns a StringBuffer with an xpath like expression of
jsfid that describes the Stack of ComponentBean . |
void |
destroy()
The destroy method is invoked to clean up resources.
|
protected Stack |
getAssociations(ComponentBean b)
Walks up the hasA parent chain looking for circular
relationships.
|
protected ConfigBean.ConfigDefinition[] |
getConfigDefinitions(String configFiles)
Passed a comma delimited list of configuration files, this method returns
an array of
ConfigBean.ConfigDefinition defining the files. |
ComponentBean |
getElement(String jsfid)
Factory method that returns a top-level {link ComponentBean} with a
matching
jsfid or null if not found. |
protected Stack |
getGeneralizations(ComponentBean b)
Walks up the isA parent chain looking for circular
relationships.
|
javax.servlet.ServletContext |
getServletContext()
Returns the web container ServletContext.
|
protected ComponentBean |
getTopLevelElement(String jsfid)
Returns the root metadata component that is used to add to the component
tree.
|
int |
getWeight()
The weight is an attempt to make a plug-able system for
registering
ConfigBean objects with the ConfigBeanFactory . |
void |
init(javax.servlet.ServletContext context)
Initialization method that is passed the
ServletContext
as a parameter. |
boolean |
isDesigntime()
Returns
true if the current mode
is design time. |
protected boolean |
isNamingContainer(String componentType)
Checks the
componentType against the NAMING_CONTAINER_TYPES
list to determine if it is a naming container. |
protected void |
loadConfigFiles()
Loads the
Clay configration files
into the displayElements Map. |
protected void |
realizingInheritance(AttributeBean a)
This overload handles fixing up
AttributeBean
inheritance. |
void |
realizingInheritance(ComponentBean b)
This method is passed a
ComponentBean and is
recursively called for each contained component. |
boolean |
refresh(boolean forceReload)
This method should be called from key points in the application to invoke
automatic reloading of the configuration files if they have been modified since
last reloaded.
|
void |
resolveInheritance()
This method is called on startup to resolve the meta inheritance relationships for
each top-level components in the
displayElements collection. |
void |
setDesigntime(boolean isDesigntime)
Sets the design time to somthing other than
the default
false value. |
protected void |
unassignParent(ComponentBean b)
Recursively called to unassign isA and hasA parent
relationships.
|
boolean |
validMoniker(String id)
Called by the
ConfigBeanFactory to determine if this
instance of ConfigBean can handle finding the ConfigBean
from the jsfid . |
protected ClayConfigParser parser
Uses the digester to load the configuration files
into a object graph cached in displayElements
.
protected boolean isWatchDogOn
This parameter is initialized from the init
method from the org.apache.shale.clay.AUTO_RELOAD_CONFIG_FILES
init
parameter in the web.xml. The default value is true
which will trigger reloading the files when a change has occurred.
protected Map watchDogs
Map of ComponentConfigBean.WatchDog
that watches the configuration files looking for changes.
The configuration files are defined by the ConfigBean.ConfigDefinition
top level
interface.
protected static Messages messages
Message resources for this class.
protected String[] suffixes
The suffixes used to identify that a jsfid is a template style of
composition. If it has a matching suffix, it will be handled
by the TemplateConfigBean
or TemplateComponentConfigBean
;
Otherwise, it's handled by ComponentConfigBean
.
protected transient javax.servlet.ServletContext context
Reference to the ServletContext
.
protected Map displayElements
Collection holding all the top-level components defined in the XML config files.
protected static final String[] NAMING_CONTAINER_TYPES
A static string array of faces component types that are naming containers.
public ComponentConfigBean()
Constructor initializes the displayElements
collection.
public boolean isDesigntime()
Returns true
if the current mode
is design time.
true
if design timepublic void setDesigntime(boolean isDesigntime)
Sets the design time to somthing other than
the default false
value.
isDesigntime
- load config descriptionspublic void init(javax.servlet.ServletContext context)
Initialization method that is passed the ServletContext
as a parameter. Loads the sufixes
for the ServletContext
initialization parameter.
init
in interface ConfigBean
context
- servlet contextprotected void loadConfigFiles()
Loads the Clay
configration files
into the displayElements
Map. The files are defined by the
clay-template-suffix
initialization parameter in the web deployment
descriptor. The default configuration file "META-INF/view-config.xml" is always
loaded from the shale-clay java archive.
protected ConfigBean.ConfigDefinition[] getConfigDefinitions(String configFiles)
Passed a comma delimited list of configuration files, this method returns
an array of ConfigBean.ConfigDefinition
defining the files.
configFiles
- comma seperated list of config filespublic javax.servlet.ServletContext getServletContext()
Returns the web container ServletContext.
getServletContext
in interface ConfigBean
public ComponentBean getElement(String jsfid)
Factory method that returns a top-level {link ComponentBean} with a
matching jsfid
or null
if not found.
getElement
in interface ConfigBean
jsfid
- id of component definitionpublic void addChild(ComponentBean obj)
Adds a {link ComponentBean} to the displayElement
map collection using
the jsfid
as the key.
obj
- component bean added to the map of elementspublic void resolveInheritance()
This method is called on startup to resolve the meta inheritance relationships for
each top-level components in the displayElements
collection. There are
three steps, find parents, check for circular relationships, and realize the relationships.
protected ComponentBean getTopLevelElement(String jsfid)
Returns the root metadata component that is used to add to the component
tree. This method might be overridden to broaden the scope to search for
components outside of the displayElement
cache.
jsfid
- id of a component beanpublic void assignParent(ComponentBean b)
Called to assign the IsA parent to the ComponentBean
using the extends
attribute.
assignParent
in interface ConfigBean
b
- component bean needing isa parent assignedprotected void realizingInheritance(AttributeBean a)
This overload handles fixing up AttributeBean
inheritance.
a
- attribute needing inheritance resolvedpublic void realizingInheritance(ComponentBean b)
This method is passed a ComponentBean
and is
recursively called for each contained component. It fixes up
the meta inheritance relationships.
realizingInheritance
in interface ConfigBean
b
- component bean needing inheritance realizedprotected Stack getGeneralizations(ComponentBean b)
Walks up the isA parent chain looking for circular
relationships. It returns a Stack of ComponentBean
documenting the heritage. A runtime exception is thrown if
a circular relationship is found.
b
- component bean having inheritance checkedprotected Stack getAssociations(ComponentBean b)
Walks up the hasA parent chain looking for circular
relationships. It returns a Stack of ComponentBean
documenting the composition. A runtime exception is thrown if
a circular relationship is found.
b
- component bean having composition checkedprotected StringBuffer describeRelationships(Stack heritage)
Returns a StringBuffer with an xpath like expression of
jsfid
that describes the Stack of ComponentBean
.
heritage
- stack of relationships to report onprotected void checkCircularInheritance(ComponentBean b)
Passed a ComponentBean
, the method looks for several
types of circular inheritances. It's recursively called for all
contained components, children, validators, actionListeners,
valueChangeListeners and Converter. A runtime exception is
thrown if a invalid relationship is found.
b
- component bean to checkprotected void unassignParent(ComponentBean b)
Recursively called to unassign isA and hasA parent relationships.
b
- component beanprotected void clear(String watchDogName)
Cleans up before a group of files are reloaded.
watchDogName
- group name for a group of config files or templatespublic void destroy()
The destroy method is invoked to clean up resources. By dereferencing the complex graph of display elements
destroy
in interface ConfigBean
public boolean validMoniker(String id)
Called by the ConfigBeanFactory
to determine if this
instance of ConfigBean
can handle finding the ConfigBean
from the jsfid
.
validMoniker
in interface ConfigBean
id
- jsfidtrue
if the jsfid can be handledpublic int compareTo(Object config)
Implementation of the Comparable interface. The weight
is used to determine the ordering of the registered ConfigBean
objects within the ConfigBeanFactory
.
compareTo
in interface Comparable
config
- object to compare topublic int getWeight()
The weight is an attempt to make a plug-able system for
registering ConfigBean
objects with the ConfigBeanFactory
.
A custom implementation could be registered for a different composition
technique adding or overriding an existing implementation.
getWeight
in interface ConfigBean
0
public boolean refresh(boolean forceReload)
This method should be called from key points in the application to invoke
automatic reloading of the configuration files if they have been modified since
last reloaded. If the forceReload
flag is true
the files are
reloaded. A true
return value indicates the config files
were reloaded.
refresh
in interface ConfigBean
forceReload
- reload the filesprotected boolean isNamingContainer(String componentType)
Checks the componentType
against the NAMING_CONTAINER_TYPES
list to determine if it is a naming container. Component id's must be unique within a
naming container. Returns a true
value if the componentType
is a naming container; otherwise, returns false
.
componentType
- type of the componenttrue
if the component type is a naming comtainerpublic void checkTree(ComponentBean b)
Recursively walks the tree of component metadata verifying
there is not a duplicate component id within a naming container.
A root ComponentBean
is passed as a single parameter.
The overloaded checkTree(List, ComponentBean)
is
invoked to process components under a naming container.
checkTree
in interface ConfigBean
b
- root of the component treeprotected void checkTree(List componentIds, ComponentBean b)
Verifies there is not a duplicate component id within a naming container.
A list of accumulating componentIds
and a
root ComponentBean
is passed as parameters. A runtime
exception is thrown if a duplicate id is encountered.
componentIds
- list of component id's in the naming containerb
- parent component beanCopyright © 2004-2013 Apache Software Foundation. All Rights Reserved.