Class I18nFactorySet
java.lang.Object
org.apache.struts.tiles.xmlDefinition.FactorySet
org.apache.struts.tiles.xmlDefinition.I18nFactorySet
- All Implemented Interfaces:
 Serializable,ComponentDefinitionsFactory
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
 the Locale found in 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:
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]Possible definition filenames.protected DefinitionsFactoryDefault factory.static final StringConfig file parameter name.static final StringDefault filenames extension.protected booleanDo we want validating parser.static final StringConfig file parameter name.static final StringConfig file parameter name.protected intParser detail level.protected XmlParserXML parser used.Fields inherited from class org.apache.struts.tiles.xmlDefinition.FactorySet
factories - 
Constructor Summary
ConstructorsConstructorDescriptionParameterless Constructor.I18nFactorySet(ServletContext servletContext, Map<String, Object> properties) Constructor. - 
Method Summary
Modifier and TypeMethodDescriptionprotected DefinitionsFactorycreateDefaultFactory(ServletContext servletContext) Create default factory .protected DefinitionsFactorycreateFactory(Object key, ServletRequest request, ServletContext servletContext) Create a factory for specified key.protected DefinitionsFactoryGet default factory.protected ObjectgetDefinitionsFactoryKey(String name, ServletRequest request, ServletContext servletContext) Extract key that will be used to get the sub factory.protected voidinitFactory(ServletContext servletContext, String proposedFilename) Initialization method.voidinitFactory(ServletContext servletContext, Map<String, Object> properties) Initialization method.protected XmlDefinitionsSetparseXmlFile(ServletContext servletContext, String filename, XmlDefinitionsSet xmlDefinitions) Parse specified xml file and add definition to specified definitions set.protected XmlDefinitionsSetparseXmlFiles(ServletContext servletContext, String postfix, XmlDefinitionsSet xmlDefinitions) Parse files associated to postix if they exist.toString()Return String representation.Methods inherited from class org.apache.struts.tiles.xmlDefinition.FactorySet
getDefinition, getFactory 
- 
Field Details
- 
DEFINITIONS_CONFIG_PARAMETER_NAME
Config file parameter name.- See Also:
 
 - 
PARSER_DETAILS_PARAMETER_NAME
Config file parameter name.- See Also:
 
 - 
PARSER_VALIDATE_PARAMETER_NAME
Config file parameter name.- See Also:
 
 - 
DEFAULT_DEFINITION_FILENAMES
Possible definition filenames. - 
FILENAME_EXTENSION
Default filenames extension.- See Also:
 
 - 
defaultFactory
Default factory. - 
xmlParser
XML parser used. Attribute is transient to allow serialization. In this implementaiton, xmlParser is created each time we need it ;-(. - 
isValidatingParser
protected boolean isValidatingParserDo we want validating parser. Default isfalse. Can be set from servlet config file. - 
parserDetailLevel
protected int parserDetailLevelParser detail level. Default is 0. Can be set from servlet config file. 
 - 
 - 
Constructor Details
- 
I18nFactorySet
public I18nFactorySet()Parameterless Constructor. MethodinitFactory(jakarta.servlet.ServletContext, java.util.Map<java.lang.String, java.lang.Object>)must be called prior to any use of created factory. - 
I18nFactorySet
public I18nFactorySet(ServletContext servletContext, Map<String, Object> properties) throws DefinitionsFactoryExceptionConstructor. Init the factory by reading appropriate configuration file.- Parameters:
 servletContext- Servlet context.properties- Map containing all properties.- Throws:
 FactoryNotFoundException- Can't find factory configuration file.DefinitionsFactoryException
 
 - 
 - 
Method Details
- 
initFactory
public void initFactory(ServletContext servletContext, Map<String, Object> properties) throws DefinitionsFactoryExceptionInitialization 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:
 initFactoryin interfaceComponentDefinitionsFactory- Specified by:
 initFactoryin classFactorySet- 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:
 DefinitionsFactoryException- An error occur during initialization.
 - 
initFactory
protected void initFactory(ServletContext servletContext, String proposedFilename) throws DefinitionsFactoryException, 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:
 DefinitionsFactoryException- An error occur during initialization.FileNotFoundException
 - 
getDefaultFactory
Get default factory.- Specified by:
 getDefaultFactoryin classFactorySet- Returns:
 - Default factory
 
 - 
createDefaultFactory
protected DefinitionsFactory createDefaultFactory(ServletContext servletContext) throws DefinitionsFactoryException, FileNotFoundException Create default factory . Create InstancesMapper for specified Locale. If creation failes, use default mapper and log error message.- Parameters:
 servletContext- Current servlet context. Used to open file.- Returns:
 - Created default definition factory.
 - Throws:
 DefinitionsFactoryException- If an error occur while creating factory.FileNotFoundException- if factory can't be loaded from filenames.
 - 
getDefinitionsFactoryKey
protected Object getDefinitionsFactoryKey(String name, ServletRequest request, ServletContext servletContext) Extract key that will be used to get the sub factory.- Specified by:
 getDefinitionsFactoryKeyin classFactorySet- Parameters:
 name- Name of requested definitionrequest- Current servlet request.servletContext- Current servlet context.- Returns:
 - the key or 
nullif not found. 
 - 
createFactory
protected DefinitionsFactory createFactory(Object key, ServletRequest request, ServletContext servletContext) throws DefinitionsFactoryException Create a factory for specified key. If creation failes, return default factory and log an error message.- Specified by:
 createFactoryin classFactorySet- Parameters:
 key- The key.request- Servlet request.servletContext- Servlet context.- Returns:
 - Definition factory for specified key.
 - Throws:
 DefinitionsFactoryException- If an error occur while creating factory.
 - 
parseXmlFiles
protected XmlDefinitionsSet parseXmlFiles(ServletContext servletContext, String postfix, XmlDefinitionsSet xmlDefinitions) throws DefinitionsFactoryException Parse files associated to postix if they exist. For each name in filenames, append postfix before file extension, then try to load the corresponding file. If file doesn't exist, try next one. Each file description is added to the XmlDefinitionsSet description. The XmlDefinitionsSet description is created only if there is a definition file. Inheritance is not resolved in the returned XmlDefinitionsSet. If no description file can be opened and no definiion set is provided, returnnull.- Parameters:
 postfix- Postfix to add to each description file.xmlDefinitions- Definitions set to which definitions will be added. Ifnull, a definitions set is created on request.- Returns:
 - XmlDefinitionsSet The definitions set created or passed as parameter.
 - Throws:
 DefinitionsFactoryException- On errors parsing file.
 - 
parseXmlFile
protected XmlDefinitionsSet parseXmlFile(ServletContext servletContext, String filename, XmlDefinitionsSet xmlDefinitions) throws DefinitionsFactoryException Parse specified xml file and add definition to specified definitions set. This method is used to load several description files in one instances list. If filename exists and definition set isnull, create a new set. Otherwise, return passed definition set (can benull).- Parameters:
 servletContext- Current servlet context. Used to open file.filename- Name of file to parse.xmlDefinitions- Definitions set to which definitions will be added. If null, a definitions set is created on request.- Returns:
 - XmlDefinitionsSet The definitions set created or passed as parameter.
 - Throws:
 DefinitionsFactoryException- On errors parsing file.
 - 
toString
Return String representation.- Overrides:
 toStringin classFactorySet- Returns:
 - String representation.
 
 
 -