Class FactorySet
java.lang.Object
org.apache.struts.tiles.xmlDefinition.FactorySet
- All Implemented Interfaces:
Serializable
,ComponentDefinitionsFactory
- Direct Known Subclasses:
I18nFactorySet
Component Definitions factory.
This factory contains several factories identified by a key. The
getDefinition() method first looks for the factory key, retrieves or creates this
factory and then calls its getDefinition().
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DefinitionsFactory
createFactory
(Object key, ServletRequest request, ServletContext servletContext) Create a factory for specified key.protected abstract DefinitionsFactory
Get default factory.getDefinition
(String name, ServletRequest request, ServletContext servletContext) Get a definition by its name.protected abstract Object
getDefinitionsFactoryKey
(String name, ServletRequest request, ServletContext servletContext) Extract key that will be used to get the sub factory.protected DefinitionsFactory
getFactory
(Object key, ServletRequest request, ServletContext servletContext) Get a factory by its key.abstract void
initFactory
(ServletContext servletContext, Map<String, Object> properties) Init factory set.toString()
Return String representation.
-
Field Details
-
factories
Loaded factories
-
-
Constructor Details
-
FactorySet
public FactorySet()Constructor.
-
-
Method Details
-
getDefinitionsFactoryKey
protected abstract Object getDefinitionsFactoryKey(String name, ServletRequest request, ServletContext servletContext) Extract key that will be used to get the sub factory.- Parameters:
name
- Name of requested definition.request
- Current servlet request.servletContext
- Current servlet context.- Returns:
- Object.
-
getDefaultFactory
Get default factory.- Returns:
- Default factory.
-
getFactory
protected DefinitionsFactory getFactory(Object key, ServletRequest request, ServletContext servletContext) throws DefinitionsFactoryException Get a factory by its key. If key isnull
, return defaultFactory. Search in loaded factories. If not found, create factory and store return value in loaded factories.- Parameters:
key
- Key of requested definition.request
- Current servlet request.servletContext
- Current servlet context.- Throws:
DefinitionsFactoryException
- If an error occur while creating factory.
-
getDefinition
public ComponentDefinition getDefinition(String name, ServletRequest request, ServletContext servletContext) throws NoSuchDefinitionException, DefinitionsFactoryException Get a definition by its name.- Specified by:
getDefinition
in interfaceComponentDefinitionsFactory
- Parameters:
name
- Name of requested definition.request
- Current servlet request.servletContext
- Current servlet context.- Throws:
NoSuchDefinitionException
- No definition found for specified nameDefinitionsFactoryException
- General exception
-
createFactory
protected abstract DefinitionsFactory createFactory(Object key, ServletRequest request, ServletContext servletContext) throws DefinitionsFactoryException Create a factory for specified key. This method is called by getFactory() when the requested factory doesn't already exist. Must return a factory, or a default one. Real implementation needs to provide this method.- Parameters:
key
- Key of requested definition.request
- Current servlet request.servletContext
- Current servlet context- Throws:
DefinitionsFactoryException
- If an error occur while creating factory.
-
initFactory
public abstract void initFactory(ServletContext servletContext, Map<String, Object> properties) throws DefinitionsFactoryExceptionInit factory set.- Specified by:
initFactory
in interfaceComponentDefinitionsFactory
- Parameters:
servletContext
- Current servlet contextproperties
- properties used to initialized factory set;- Throws:
DefinitionsFactoryException
- An error occur during initialization.
-
toString
Return String representation.
-