org.apache.struts.tiles.xmlDefinition
Class FactorySet

java.lang.Object
  |
  +--org.apache.struts.tiles.xmlDefinition.FactorySet
All Implemented Interfaces:
ComponentDefinitionsFactory, java.io.Serializable
Direct Known Subclasses:
I18nFactorySet

public abstract class FactorySet
extends java.lang.Object
implements ComponentDefinitionsFactory

Component Definitions factory. This factory contains several factories identified by a key. The getDefinition() method first look for the factory key, retrieve or create this factory and then call getDefinition() on the found factory.

See Also:
Serialized Form

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

Field Detail

factories

protected java.util.Map factories
Loaded factories

Constructor Detail

FactorySet

public FactorySet()
Method Detail

getDefinitionsFactoryKey

protected abstract 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.

Parameters:
name - Name of requested definition
request - Current servlet request.
servletContext - Current servlet context

getDefaultFactory

protected abstract DefinitionsFactory getDefaultFactory()
Get default factory.

Returns:
Default factory

getFactory

protected DefinitionsFactory getFactory(java.lang.Object key,
                                        javax.servlet.ServletRequest request,
                                        javax.servlet.ServletContext servletContext)
                                 throws DefinitionsFactoryException
Get a factory by its key. If key is null, return defaultFactory. Search in loaded factory. If not found, call 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(java.lang.String name,
                                         javax.servlet.ServletRequest request,
                                         javax.servlet.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:
DefinitionsFactoryException - An error occur while getting definition.
NoSuchDefinitionException - No definition found for specified name
DefinitionsFactoryException - General exception

createFactory

protected abstract DefinitionsFactory createFactory(java.lang.Object key,
                                                    javax.servlet.ServletRequest request,
                                                    javax.servlet.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, even a default one. Real implementation need 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(javax.servlet.ServletContext servletContext,
                                 java.util.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 java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright 2000-2002 - Cedric Dumoulin and Apache Software Foundation