|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IObjectCreator
NOTICE: This class is deprecated and will not exist in platform version 2.1.
Below is a guide for how to use the new API for factory-ing dynamic objects:
The old way of creating objects via a factory was:
1. PentahoObjectFactory fac = new PentahoObjectFactory();
//set the object specifications (as a map of object creators)
//the object creator classes provided scoping to objects,
//allowing us to bind object to particular scopes
2. SessionObjectCreator creator = SessionObjectCreator("org.pentaho.platform.api.repository.ISolutionRepository")
3. Map objCreatorMap = new HashMap()
4. objCreatorMap.put("ISolutionRepository", creator)
5. fac.setObjectCreators(objCreatorMap);
6. ISolutionEngine eng = (ISolutionEngine)fac.getObject("ISolutionEngine", session);
The new way of factory-ing objects is:
1. IPentahoObjectFactory fac = new MyPentahoObjectFactory();
//configure the factory with an object specification file and/or a runtime context object
2. fac.init(objectSpecFile, contextObject) IPentahoObjectFactory.init(String, Object)
3. ISolutionEngine eng = fac.get(ISolutionEngine.class, session) IPentahoObjectFactory.get(Class, IPentahoSession)
You will notice that the new way of serving up objects does not expose an API for scoping of objects like the old way did.
This behavior is now delegated to the particular IPentahoObjectFactory
implementation, which means a factory
implementation has total freedom to be as simple or sophisticated at it wants without being required to handle object
scoping. Any kind of object binding/scoping or any other rules for the creation and management of objects is totally
up the implementation. Typically, a factory implementation would be made aware of it's rules for object creation by way of a well-known objectSpecFile (see
new way step #2 in the instructions above).
Method Summary | |
---|---|
Object |
getInstance(String key,
IPentahoSession session)
Deprecated. |
void |
setClassLoader(ClassLoader classLoader)
Deprecated. |
Method Detail |
---|
Object getInstance(String key, IPentahoSession session) throws ObjectFactoryException
IObjectCreator
ObjectFactoryException
void setClassLoader(ClassLoader classLoader)
IObjectCreator
Sets the classloader to be used to create objects. If this is not set the implementor can use a classloader of its choosing
classLoader
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |