|
SAP NetWeaver '04 | |||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
See:
Description
| Class Summary | |
| AbstractObjectFactory | A factory which produces configurable objects. |
| ReflectionUtils | A wrapper for reflection methods with an WcmException . |
| ThreadUtils | Some tools for starting threads. |
Provides base classes for factory implementations.
SampleWcmObjects, would look like that:
public class SampleWcmObjectFactory
extends AbstractClassFactory {
private static final String ID = "samplewcmobject";
public SampleWcmObjectFactory(String id) {
super("SampleWcmObjectFactory", id);
}
protected void onInitialize()
throws WcmException {
readConfig();
loadClass();
}
protected static SchedulerFactory getInstance()
throws WcmException {
return (SampleWcmObjectFactory)getFactoryInstance(SampleWcmObjectFactory.class, SINGLETON, ID);
}
public static ISampleWcmObject getSampleWcmObject()
throws WcmException {
return (ISampleWcmObject)getInstance().getClassInstance();
}
}
To get an object from the factory, one would call the getSampleWcmObject()
method, wich will call getInstance() at first:getInstance() calls the AbstractClassFactory's method
getFactoryInstance(). This method expects the class-object of the factory,
the type of instanciation (SINGLETON or MULTI)
and the id for the factory as parameters. It will call the given classes constructor,
passing the id as the constructors parameter. The constructor initializes the base
class by calling the AbstractClassFactory's constructor via
super().getFactoryInstance() calls the
factories method onInitialize(). The onInitialize() method should
do two things:
readConfig() loads the configuration data (the WCM config properties,
prefixed by the id of the factory).loadClass() loads the class with the name defined in the id.class
config property (samplewcmobject.class in the sample code).getInstance() to
getSampleWcmObject() and the AbstractClassFactory's method
getClassInstance() is called. This method calls the constructor of the class
loaded by loadClass(), passing the config properties as the parameter to
this constructor.
Therefore, a constructor for SampleWcmObjects should look like this:
public class SampleWcmObject implements ISampleWcmObject {
public SampleWcmObject(Properities property) {
}
}
Such an object will be dynamically created by a call to
SampleWcmObjectFactory.getSampleWcmObject(),
if the SampleWcmObjectFactory is properly configured (with the config entry:
).samplewcmobject.class = SampleWcmObject
|
SAP NetWeaver '04 | |||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||