| java.lang.Object org.apache.commons.chain.CatalogFactory
All known Subclasses: org.apache.commons.chain.impl.CatalogFactoryBase,
CatalogFactory | abstract public class CatalogFactory (Code) | | A
CatalogFactory is a class used to store and retrieve
Catalog s. The factory allows for a default
Catalog as well as
Catalog s stored with a name key. Follows the
Factory pattern (see GoF).
The base CatalogFactory implementation also implements
a resolution mechanism which allows lookup of a command based on a single
String which encodes both the catalog and command names.
author: Sean Schofield version: $Revision: 411893 $ $Date: 2006-06-05 19:59:05 +0100 (Mon, 05 Jun 2006) $ |
Method Summary | |
abstract public void | addCatalog(String name, Catalog catalog) | public static void | clear() Clear all references to registered catalogs, as well as to the
relevant class loader. | abstract public Catalog | getCatalog() | abstract public Catalog | getCatalog(String name) | public Command | getCommand(String commandID) Return a Command based on the given commandID.
At this time, the structure of commandID is relatively simple: if the
commandID contains a DELIMITER, treat the segment of the commandID
up to (but not including) the DELIMITER as the name of a catalog, and the
segment following the DELIMITER as a command name within that catalog.
If the commandID contains no DELIMITER, treat the commandID as the name
of a command in the default catalog.
To preserve the possibility of future extensions to this lookup
mechanism, the DELIMITER string should be considered reserved, and
should not be used in command names. | public static CatalogFactory | getInstance() Return the singleton
CatalogFactory instance
for the relevant ClassLoader . | abstract public Iterator | getNames() Return an Iterator over the set of named
Catalog s known to this
CatalogFactory . | abstract public void | setCatalog(Catalog catalog) |
DELIMITER | final public static String DELIMITER(Code) | | Values passed to the getCommand(String) method should
use this as the delimiter between the "catalog" name and the "command"
name.
|
addCatalog | abstract public void addCatalog(String name, Catalog catalog)(Code) | | Adds a named instance of Catalog to the factory (for subsequent
retrieval later).
Parameters: name - the name of the Catalog to add Parameters: catalog - the Catalog to add |
clear | public static void clear()(Code) | | Clear all references to registered catalogs, as well as to the
relevant class loader. This method should be called, for example,
when a web application utilizing this class is removed from
service, to allow for garbage collection.
|
getCatalog | abstract public Catalog getCatalog()(Code) | | Gets the default instance of Catalog associated with the factory
(if any); otherwise, return null .
the default Catalog instance |
getCatalog | abstract public Catalog getCatalog(String name)(Code) | | Retrieves a Catalog instance by name (if any); otherwise
return null .
Parameters: name - the name of the Catalog to retrieve the specified Catalog |
getCommand | public Command getCommand(String commandID)(Code) | | Return a Command based on the given commandID.
At this time, the structure of commandID is relatively simple: if the
commandID contains a DELIMITER, treat the segment of the commandID
up to (but not including) the DELIMITER as the name of a catalog, and the
segment following the DELIMITER as a command name within that catalog.
If the commandID contains no DELIMITER, treat the commandID as the name
of a command in the default catalog.
To preserve the possibility of future extensions to this lookup
mechanism, the DELIMITER string should be considered reserved, and
should not be used in command names. commandID values which contain
more than one DELIMITER will cause an
IllegalArgumentException to be thrown.
Parameters: commandID - the identifier of the command to return the command located with commandID, or null if either the command name or the catalog name cannot be resolved throws: IllegalArgumentException - if the commandID contains more thanone DELIMITER since: Chain 1.1 |
getInstance | public static CatalogFactory getInstance()(Code) | | Return the singleton
CatalogFactory instance
for the relevant ClassLoader . For applications
that use a thread context class loader (such as web applications
running inside a servet container), this will return a separate
instance for each application, even if this class is loaded from
a shared parent class loader.
the per-application singleton instance of CatalogFactory |
getNames | abstract public Iterator getNames()(Code) | | Return an Iterator over the set of named
Catalog s known to this
CatalogFactory .
If there are no known catalogs, an empty Iterator is returned.
An Iterator of the names of the Catalogs known by this factory. |
setCatalog | abstract public void setCatalog(Catalog catalog)(Code) | | Sets the default instance of Catalog associated with the factory.
Parameters: catalog - the default Catalog instance |
|
|