org.apache.struts.tiles.xmlDefinition
Class FactorySet

java.lang.Object
  extended by org.apache.struts.tiles.xmlDefinition.FactorySet
All Implemented Interfaces:
Serializable, ComponentDefinitionsFactory
Direct Known Subclasses:
I18nFactorySet

public abstract class FactorySet
extends Object
implements ComponentDefinitionsFactory

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:
Serialized Form

Field Summary
protected  Map factories
          Loaded factories
 
Constructor Summary
FactorySet()
          Constructor.
 
Method Summary
protected abstract  DefinitionsFactory createFactory(Object key, ServletRequest request, ServletContext servletContext)
          Create a factory for specified key.
protected abstract  DefinitionsFactory getDefaultFactory()
          Get default factory.
 ComponentDefinition 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 properties)
          Init factory set.
 String toString()
          Return String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

factories

protected Map factories
Loaded factories

Constructor Detail

FactorySet

public FactorySet()
Constructor.

Method Detail

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

protected abstract DefinitionsFactory 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 is null, 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 interface ComponentDefinitionsFactory
Parameters:
name - Name of requested definition.
request - Current servlet request.
servletContext - Current servlet context.
Throws:
NoSuchDefinitionException - No definition found for specified name
DefinitionsFactoryException - 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 properties)
                          throws DefinitionsFactoryException
Init factory set.

Specified by:
initFactory in interface ComponentDefinitionsFactory
Parameters:
servletContext - Current servlet context
properties - properties used to initialized factory set;
Throws:
DefinitionsFactoryException - An error occur during initialization.

toString

public String toString()
Return String representation.

Overrides:
toString in class Object
Returns:
String representation.


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.