SAP NetWeaver '04

com.sapportals.wcm.util.factories
Class AbstractObjectFactory

[contained in: com.sap.netweaver.bc.util.par - bc.util.public_api.jar]
java.lang.Object
  |
  +--com.sapportals.wcm.util.factories.AbstractObjectFactory
Direct Known Subclasses:
ChannelFactory, RecipientFactory

public abstract class AbstractObjectFactory
extends java.lang.Object

A factory which produces configurable objects.

The classes to load are specified by the classname from the configuration properties.
The objects classes are specified by a commata separated list in the configuration, e.g.:
factory .list = id , id , ...
For each id at least a classname has to be specified and an optional singleton flag, e.g.:
factory . id .class = classname
factory . id .singleton = true
Additional parameters in the form
factory . id . xxx = ...
can be passed to the object's constructor.


Inner Class Summary
protected  class AbstractObjectFactory.ObjectClassEntry
          An object class entry represents the information about the several objects to be created by the factory.
 
Field Summary
protected static java.lang.String CONFIG_OBJECTLIST_SEPARATOR
          Configuration value for the object id list separator.
protected static java.lang.String CONFIG_OBJECTLIST_TAG
          Configuration tag for the object id list.
protected static java.lang.String CONFIG_SINGLETON_DEFAULT
          Default configuration value for the singleton flag.
protected static java.lang.String CONFIG_SINGLETON_TAG
          Configuration tag for the singleton flag.
protected  java.lang.String m_ID
          The id of the factory.
protected  java.lang.String m_LogName
          A short name for logging.
protected  java.util.HashMap m_ObjectMap
          The map of ObjectClassEntrys, indexed by object class id.
protected  java.util.Properties m_Properties
          The properties (with prefix factory -id) from the config file.
protected static int MULTI
          Code for a multi-instance AbstractObjectFactory .
protected static int SINGLETON
          Code for a singleton AbstractObjectFactory (singleton per id).
 
Constructor Summary
  AbstractObjectFactory(java.lang.String id)
          Create an AbstractObjectFactory for a given factory-id .
protected AbstractObjectFactory(java.lang.String logName, java.lang.String id)
          Create an AbstractObjectFactory for a given factory-id .
 
Method Summary
 java.util.Collection getAllObjectInstances()
          Get a list with one instance for each available object class.
protected static AbstractObjectFactory getFactoryInstance(java.lang.String id, java.lang.Class classObject, int instanceType)
          Get an initialized instance of a factory for the given id .
protected  java.lang.Object[] getObjectConstructorParameters(java.lang.String id, java.util.Properties properties)
          Get the actual parameter for the object's constructor.
protected  java.lang.Class[] getObjectConstructorParameterTypes(java.lang.String id)
          Get the parameter types for the object classes' constructor.
protected  java.lang.Object getObjectInstance(java.lang.String id)
          Create a new instance from the ObjectClassEntry for the given id.
protected  java.util.HashMap loadObjectMap(com.sapportals.config.fwk.IConfigurable[] configurables)
           
protected  java.util.HashMap loadObjectMap(java.lang.String list, java.lang.String listSeparator, java.util.Properties properties)
          Load the object classes into a map with pairs of id , ObjectEntry s.
protected  AbstractObjectFactory.ObjectClassEntry newObjectListEntry(java.lang.String id, java.lang.reflect.Constructor constructor, java.util.Properties properties, boolean singletonFlag)
          Create a new object class entry for the object class list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_LogName

protected java.lang.String m_LogName
A short name for logging.

m_ID

protected java.lang.String m_ID
The id of the factory.

m_Properties

protected java.util.Properties m_Properties
The properties (with prefix factory -id) from the config file.

m_ObjectMap

protected java.util.HashMap m_ObjectMap
The map of ObjectClassEntrys, indexed by object class id.

CONFIG_OBJECTLIST_TAG

protected static final java.lang.String CONFIG_OBJECTLIST_TAG
Configuration tag for the object id list.

CONFIG_OBJECTLIST_SEPARATOR

protected static final java.lang.String CONFIG_OBJECTLIST_SEPARATOR
Configuration value for the object id list separator.

CONFIG_SINGLETON_TAG

protected static final java.lang.String CONFIG_SINGLETON_TAG
Configuration tag for the singleton flag.

CONFIG_SINGLETON_DEFAULT

protected static final java.lang.String CONFIG_SINGLETON_DEFAULT
Default configuration value for the singleton flag.

SINGLETON

protected static final int SINGLETON
Code for a singleton AbstractObjectFactory (singleton per id).

MULTI

protected static final int MULTI
Code for a multi-instance AbstractObjectFactory .
Constructor Detail

AbstractObjectFactory

public AbstractObjectFactory(java.lang.String id)
                      throws WcmException
Create an AbstractObjectFactory for a given factory-id . Should call super( logName , id ) . Note : This constructor has to be public (although it should be protected), to allow the abstract factory the creation of a new derived factories via reflection.
Parameters:
id - a String with the unique id of the factory used as a prefix for the configuration parameters.
Throws:
WcmException - Exception raised in failure situation

AbstractObjectFactory

protected AbstractObjectFactory(java.lang.String logName,
                                java.lang.String id)
                         throws WcmException
Create an AbstractObjectFactory for a given factory-id . Note : This constructor has to be public (although it should be protected), to allow the newFactory() -method the creation of new factories.
Parameters:
logName - a String with the factory's short name (for logging).
id - a String with the unique id of the factory used as a prefix for the configuration parameters.
Throws:
WcmException - Exception raised in failure situation
Method Detail

getAllObjectInstances

public java.util.Collection getAllObjectInstances()
                                           throws WcmException
Get a list with one instance for each available object class.
Returns:
a Collection of Object s, which may be empty if no object class exists.
Throws:
WcmException - if an error occured while creating the list.

getObjectConstructorParameterTypes

protected java.lang.Class[] getObjectConstructorParameterTypes(java.lang.String id)
Get the parameter types for the object classes' constructor.
Parameters:
id - a String with the id of the object class to get the parameter types for.
Returns:
The ObjectConstructorParameterTypes value

getObjectConstructorParameters

protected java.lang.Object[] getObjectConstructorParameters(java.lang.String id,
                                                            java.util.Properties properties)
                                                     throws WcmException
Get the actual parameter for the object's constructor.
Parameters:
id - a String with the id of the object to get the parameter for.
properties -  
Returns:
The ObjectConstructorParameters value
Throws:
WcmException - Exception raised in failure situation

getObjectInstance

protected java.lang.Object getObjectInstance(java.lang.String id)
                                      throws WcmException
Create a new instance from the ObjectClassEntry for the given id.
Parameters:
id - a String with the id of the object class.
Returns:
an Object with an instance of the requested object class specified by the id or null if the id is not found.
Throws:
WcmException - if an object cannot be created.

loadObjectMap

protected java.util.HashMap loadObjectMap(java.lang.String list,
                                          java.lang.String listSeparator,
                                          java.util.Properties properties)
                                   throws WcmException
Load the object classes into a map with pairs of id , ObjectEntry s.
Parameters:
list - a String with a list of id strings for the object classes to load.
listSeparator - a String with the separators for the list string.
properties - the Properties to use for searching the object classes class name and to pass to those object classes.
Returns:
TBD: Description
Throws:
WcmException - if an error occured.

loadObjectMap

protected java.util.HashMap loadObjectMap(com.sapportals.config.fwk.IConfigurable[] configurables)
                                   throws WcmException
Parameters:
configurables -  
Returns:
 
Throws:
WcmException - Exception raised in failure situation

newObjectListEntry

protected AbstractObjectFactory.ObjectClassEntry newObjectListEntry(java.lang.String id,
                                                                    java.lang.reflect.Constructor constructor,
                                                                    java.util.Properties properties,
                                                                    boolean singletonFlag)
Create a new object class entry for the object class list. Create a new object class entry for the object class list. Create a new object class entry for the object class list. Create a new object class entry for the object class list. Create a new object class entry for the object class list. Create a new object class entry for the object class list. Create a new object class entry for the object class list. Create a new object class entry for the object class list. Create a new object class entry for the object class list. create a new object class entry.
Parameters:
id - a String with the id of the object class.
constructor - the Constructor for the object class.
properties - the Properties for the object class.
singletonFlag - a boolean true if this object class should have only one instance, false if not.
Returns:
TDB: Description of the outgoing return value

getFactoryInstance

protected static AbstractObjectFactory getFactoryInstance(java.lang.String id,
                                                          java.lang.Class classObject,
                                                          int instanceType)
                                                   throws WcmException
Get an initialized instance of a factory for the given id . This method will handle the type code for the singleton/multi instance behavior.
Parameters:
id - a String with the id for the factory.
classObject - the Class of the (derived) factory.
instanceType - an int with the instance type ( SINGLETON or MULTI ).
Returns:
an AbstractObjectFactory with an instance of the (derived) factory as.
Throws:
WcmException - if the factory cannot be initialized.

SAP NetWeaver '04

Copyright © 2004 by SAP AG. All Rights Reserved.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.