com.free2be.dimensions.tiles
Class ChannelFactorySet

java.lang.Object
  extended by org.apache.struts.tiles.xmlDefinition.FactorySet
      extended by com.free2be.dimensions.tiles.ChannelFactorySet
All Implemented Interfaces:
java.io.Serializable, org.apache.struts.tiles.ComponentDefinitionsFactory

public class ChannelFactorySet
extends org.apache.struts.tiles.xmlDefinition.FactorySet

Definitions factory. This implementation allows to have a set of definition factories. There is a main factory, and one factory for each file associated to a Locale. To retrieve a definition, we first search for the appropriate factory, using Locale found in jsp session context. If no factory is found, use the default one. Then, we ask the factory for the definition. A definition factory file is loaded using main filename extended with locale code (ex : templateDefinitions_fr.xml). If no file is found under this name, use default file.

See Also:
Serialized Form

Field Summary
static boolean debug
          Debug flag
static java.lang.String[] DEFAULT_DEFINITION_FILENAMES
          Possible definition filenames
protected  org.apache.struts.tiles.xmlDefinition.DefinitionsFactory defaultFactory
          Default factory
static java.lang.String DEFINITIONS_CONFIG_PARAMETER_NAME
          Config file parameter name
static java.lang.String FILENAME_EXTENSION
          Default filenames extension
static java.lang.String INSTANCES_CONFIG_PARAMETER_NAME
          Deprecated. use DEFINITIONS_CONFIG_PARAMETER_NAME
protected  boolean isValidatingParser
          Does we want validating parser ?
protected static org.apache.commons.logging.Log log
           
static java.lang.String PARSER_DETAILS_PARAMETER_NAME
          Config file parameter name
static java.lang.String PARSER_VALIDATE_PARAMETER_NAME
          Config file parameter name
protected  int parserDetailLevel
          Parser detail level.
protected  org.apache.struts.tiles.xmlDefinition.XmlParser xmlParser
          Xml parser used
 
Fields inherited from class org.apache.struts.tiles.xmlDefinition.FactorySet
factories
 
Constructor Summary
ChannelFactorySet()
          Parameterless Constructor.
ChannelFactorySet(javax.servlet.ServletContext servletContext, java.util.Map properties)
          Constructor.
 
Method Summary
protected static boolean appendSuffix(java.lang.StringBuffer filename, java.lang.String suffix, java.util.List filenames)
           
protected  org.apache.struts.tiles.xmlDefinition.DefinitionsFactory createDefaultFactory(javax.servlet.ServletContext servletContext)
          Create default factory .
protected  org.apache.struts.tiles.xmlDefinition.DefinitionsFactory createFactory(java.lang.Object key, javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)
          Create a factory for specified key.
protected  org.apache.struts.tiles.xmlDefinition.DefinitionsFactory getDefaultFactory()
          Get default factory.
protected  java.lang.Object getDefinitionsFactoryKey(java.lang.String name, javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)
          Extract key that will be used to get the sub factory.
protected  org.apache.struts.tiles.xmlDefinition.DefinitionsFactory getLoadedFactory(java.lang.String postfix)
           
 void initFactory(javax.servlet.ServletContext servletContext, java.util.Map properties)
          Initialization method.
protected  void initFactory(javax.servlet.ServletContext servletContext, java.lang.String proposedFilename)
          Initialization method.
protected  org.apache.struts.tiles.xmlDefinition.DefinitionsFactory loadNewFactory(java.util.List ancestralPostfixes, org.apache.struts.tiles.xmlDefinition.XmlDefinitionsSet lastXmlFile, javax.servlet.ServletContext servletContext)
          The xml file represented by the last suffix was already read...just pass it instead of re-reading it.
 
Methods inherited from class org.apache.struts.tiles.xmlDefinition.FactorySet
getDefinition, getFactory, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static final boolean debug
Debug flag

See Also:
Constant Field Values

INSTANCES_CONFIG_PARAMETER_NAME

public static final java.lang.String INSTANCES_CONFIG_PARAMETER_NAME
Deprecated. use DEFINITIONS_CONFIG_PARAMETER_NAME
Config file parameter name

See Also:
Constant Field Values

DEFINITIONS_CONFIG_PARAMETER_NAME

public static final java.lang.String DEFINITIONS_CONFIG_PARAMETER_NAME
Config file parameter name

See Also:
Constant Field Values

PARSER_DETAILS_PARAMETER_NAME

public static final java.lang.String PARSER_DETAILS_PARAMETER_NAME
Config file parameter name

See Also:
Constant Field Values

PARSER_VALIDATE_PARAMETER_NAME

public static final java.lang.String PARSER_VALIDATE_PARAMETER_NAME
Config file parameter name

See Also:
Constant Field Values

DEFAULT_DEFINITION_FILENAMES

public static final java.lang.String[] DEFAULT_DEFINITION_FILENAMES
Possible definition filenames


defaultFactory

protected org.apache.struts.tiles.xmlDefinition.DefinitionsFactory defaultFactory
Default factory


xmlParser

protected org.apache.struts.tiles.xmlDefinition.XmlParser xmlParser
Xml parser used


isValidatingParser

protected boolean isValidatingParser
Does we want validating parser ? Default is false. Can be set from servlet config file


parserDetailLevel

protected int parserDetailLevel
Parser detail level. Default is 0. Can be set from servlet config file


log

protected static org.apache.commons.logging.Log log

FILENAME_EXTENSION

public static final java.lang.String FILENAME_EXTENSION
Default filenames extension

See Also:
Constant Field Values
Constructor Detail

ChannelFactorySet

public ChannelFactorySet()
Parameterless Constructor. Method initFactory must be called prior to any use of created factory.


ChannelFactorySet

public ChannelFactorySet(javax.servlet.ServletContext servletContext,
                         java.util.Map properties)
                  throws org.apache.struts.tiles.DefinitionsFactoryException
Constructor. Init the factory by reading appropriate configuration file.

Throws:
org.apache.struts.tiles.FactoryNotFoundException - Can't find factory configuration file.
org.apache.struts.tiles.DefinitionsFactoryException
Method Detail

initFactory

public void initFactory(javax.servlet.ServletContext servletContext,
                        java.util.Map properties)
                 throws org.apache.struts.tiles.DefinitionsFactoryException
Initialization method. Init the factory by reading appropriate configuration file. This method is called exactly once immediately after factory creation in case of internal creation (by DefinitionUtil).

Specified by:
initFactory in interface org.apache.struts.tiles.ComponentDefinitionsFactory
Specified by:
initFactory in class org.apache.struts.tiles.xmlDefinition.FactorySet
Parameters:
servletContext - Servlet Context passed to newly created factory.
properties - Map of name/property passed to newly created factory. Map can contains more properties than requested.
Throws:
org.apache.struts.tiles.DefinitionsFactoryException - An error occur during initialization.

initFactory

protected void initFactory(javax.servlet.ServletContext servletContext,
                           java.lang.String proposedFilename)
                    throws org.apache.struts.tiles.DefinitionsFactoryException,
                           java.io.FileNotFoundException
Initialization method. Init the factory by reading appropriate configuration file. This method is called exactly once immediately after factory creation in case of internal creation (by DefinitionUtil).

Parameters:
servletContext - Servlet Context passed to newly created factory.
proposedFilename - File names, comma separated, to use as base file names.
Throws:
org.apache.struts.tiles.DefinitionsFactoryException - An error occur during initialization.
java.io.FileNotFoundException

getDefaultFactory

protected org.apache.struts.tiles.xmlDefinition.DefinitionsFactory getDefaultFactory()
Get default factory.

Specified by:
getDefaultFactory in class org.apache.struts.tiles.xmlDefinition.FactorySet
Returns:
Default factory

createDefaultFactory

protected org.apache.struts.tiles.xmlDefinition.DefinitionsFactory createDefaultFactory(javax.servlet.ServletContext servletContext)
                                                                                 throws org.apache.struts.tiles.DefinitionsFactoryException,
                                                                                        java.io.FileNotFoundException
Create default factory . Create InstancesMapper for specified Locale. If creation failed, use default mapper, and output an error message in console.

Parameters:
servletContext - Current servlet context. Used to open file.
Returns:
Created default definition factory.
Throws:
org.apache.struts.tiles.DefinitionsFactoryException - If an error occur while creating factory.
java.io.FileNotFoundException - if factory can't be loaded from filenames.

getDefinitionsFactoryKey

protected java.lang.Object getDefinitionsFactoryKey(java.lang.String name,
                                                    javax.servlet.ServletRequest request,
                                                    javax.servlet.ServletContext servletContext)
Extract key that will be used to get the sub factory.

Specified by:
getDefinitionsFactoryKey in class org.apache.struts.tiles.xmlDefinition.FactorySet
Parameters:
name - Name of requested definition
request - Current servlet request.
servletContext - Current servlet context
Returns:
the key or null if not found.

createFactory

protected org.apache.struts.tiles.xmlDefinition.DefinitionsFactory createFactory(java.lang.Object key,
                                                                                 javax.servlet.ServletRequest request,
                                                                                 javax.servlet.ServletContext servletContext)
                                                                          throws org.apache.struts.tiles.DefinitionsFactoryException
Create a factory for specified key. If creation failed, return default factory, and output an error message in console.

Specified by:
createFactory in class org.apache.struts.tiles.xmlDefinition.FactorySet
Parameters:
key -
Returns:
Definition factory for specified key.
Throws:
org.apache.struts.tiles.DefinitionsFactoryException - If an error occur while creating factory.

loadNewFactory

protected org.apache.struts.tiles.xmlDefinition.DefinitionsFactory loadNewFactory(java.util.List ancestralPostfixes,
                                                                                  org.apache.struts.tiles.xmlDefinition.XmlDefinitionsSet lastXmlFile,
                                                                                  javax.servlet.ServletContext servletContext)
                                                                           throws org.apache.struts.tiles.DefinitionsFactoryException
The xml file represented by the last suffix was already read...just pass it instead of re-reading it.

Throws:
org.apache.struts.tiles.DefinitionsFactoryException

getLoadedFactory

protected org.apache.struts.tiles.xmlDefinition.DefinitionsFactory getLoadedFactory(java.lang.String postfix)

appendSuffix

protected static boolean appendSuffix(java.lang.StringBuffer filename,
                                      java.lang.String suffix,
                                      java.util.List filenames)
Returns:
true when the suffix exists.