Interface IPentahoObjectFactory
-
- All Known Subinterfaces:
IPentahoDefinableObjectFactory
,IPentahoRegistrableObjectFactory
public interface IPentahoObjectFactory
The way the BI platform creates and manages system objects.Here is an example of how the API might be used:
1. IPentahoObjectFactory fac = new MyPentahoObjectFactory();
//configure the factory with an object specification file and/or a runtime context object
2. fac.init(objectSpecFile, contextObject)init(String, Object)
3. ISolutionEngine eng = fac.get(ISolutionEngine.class, session)get(Class, IPentahoSession)
You will notice that the this way of serving up objects does not expose an API for scoping of objects. This behavior is 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 object specification file, seeinit(String, Object)
- Author:
- Aaron Phillips
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PRIORTIY
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> T
get(Class<T> interfaceClass, String key, IPentahoSession session)
Retrieves an instance of a Pentaho BI Server API interface by the given object key.<T> T
get(Class<T> interfaceClass, IPentahoSession session)
Retrieves an instance of a Pentaho BI Server API interface using the simple interface name (interfaceClass name without the package) as the object key.<T> T
get(Class<T> interfaceClass, IPentahoSession session, Map<String,String> properties)
Retrieves an instance of a Pentaho BI Server API interface using the simple interface name (interfaceClass name without the package) as the object key.<T> List<T>
getAll(Class<T> interfaceClass, IPentahoSession curSession)
Returns all objects implementing the provided interface or extending the provided class if the Class is not an Interface.<T> List<T>
getAll(Class<T> interfaceClass, IPentahoSession curSession, Map<String,String> properties)
Returns all objects implementing the provided interface or extending the provided class if the Class is not an Interface.Class<?>
getImplementingClass(String key)
Provides the concrete Class defined for the given object key.String
getName()
Return the name for this factory.<T> IPentahoObjectReference<T>
getObjectReference(Class<T> interfaceClass, IPentahoSession curSession)
Returns an IPentahoObjectReference for the requested Object containing registered Object Properties.<T> IPentahoObjectReference<T>
getObjectReference(Class<T> interfaceClass, IPentahoSession curSession, Map<String,String> properties)
Returns an IPentahoObjectReference for the requested Object containing registered Object Properties.<T> List<IPentahoObjectReference<T>>
getObjectReferences(Class<T> interfaceClass, IPentahoSession curSession)
Returns an IPentahoObjectReference for the requested Object containing registered Object Properties.<T> List<IPentahoObjectReference<T>>
getObjectReferences(Class<T> interfaceClass, IPentahoSession curSession, Map<String,String> properties)
Returns an IPentahoObjectReference for the requested Object containing registered Object Properties.void
init(String configFile, Object context)
Initialize the factory with optional configuration file and runtime context.boolean
objectDefined(Class<?> clazz)
Checks if the implementation for the given interface is defined.boolean
objectDefined(String key)
Checks if the implementation for the given interface is defined.
-
-
-
Field Detail
-
DEFAULT_PRIORTIY
static final int DEFAULT_PRIORTIY
- See Also:
- Constant Field Values
-
-
Method Detail
-
get
<T> T get(Class<T> interfaceClass, IPentahoSession session) throws ObjectFactoryException
Retrieves an instance of a Pentaho BI Server API interface using the simple interface name (interfaceClass name without the package) as the object key. If an appropriate implementation does not exist the factory implementation should create it.- Parameters:
interfaceClass
- the type of object to retrieve (retrieved object will be returned as this type)session
- the Pentaho session object. Can be used to associate an object instance to a Pentaho session. Value will be null if request to getObject does not originate in a session context.- Returns:
- the implementation object typed to interfaceClass
- Throws:
ObjectFactoryException
- if the object cannot be retrieved
-
get
<T> T get(Class<T> interfaceClass, String key, IPentahoSession session) throws ObjectFactoryException
Retrieves an instance of a Pentaho BI Server API interface by the given object key. If an appropriate implementation does not exist the factory implementation should create it.- Parameters:
interfaceClass
- the type of object to retrieve (retrieved object will be returned as this type)key
- the object identifier, typically the interface namesession
- the Pentaho session object. Can be used to associate an object instance to a Pentaho session. Value will be null if request to getObject does not originate in a session context.- Returns:
- the implementation object typed to interfaceClass
- Throws:
ObjectFactoryException
- if the object cannot be retrieved
-
get
<T> T get(Class<T> interfaceClass, IPentahoSession session, Map<String,String> properties) throws ObjectFactoryException
Retrieves an instance of a Pentaho BI Server API interface using the simple interface name (interfaceClass name without the package) as the object key. If an appropriate implementation does not exist the factory implementation should create it.- Parameters:
interfaceClass
- the type of object to retrieve (retrieved object will be returned as this type)session
- the Pentaho session object. Can be used to associate an object instance to a Pentaho session. Value will be null if request to getObject does not originate in a session context.properties
- Map of properties to filter matches in the ObjectFactory by- Returns:
- the implementation object typed to interfaceClass
- Throws:
ObjectFactoryException
- if the object cannot be retrieved
-
objectDefined
boolean objectDefined(String key)
Checks if the implementation for the given interface is defined.- Parameters:
key
- the object identifier, typically the interface name- Returns:
- true if the object is defined
-
objectDefined
boolean objectDefined(Class<?> clazz)
Checks if the implementation for the given interface is defined.- Parameters:
clazz
- Interface or class literal to search for- Returns:
- true if the object is defined
-
getImplementingClass
Class<?> getImplementingClass(String key)
Provides the concrete Class defined for the given object key.- Parameters:
key
- the object identifier, typically the interface name- Returns:
- the type of object associated with key
- Throws:
RuntimeException
- of some type indicating a problem loading or finding the implementing class
-
init
void init(String configFile, Object context)
Initialize the factory with optional configuration file and runtime context. Calling this method should also reset any state the factory may be holding, such as object definitions.- Parameters:
configFile
- an object configuration definition file understandable by the factory implementationcontext
- a context object whereby the factory implementation can access runtime information, type of object varies depending on the framework used by the factory and the environment in which the application is running.
-
getAll
<T> List<T> getAll(Class<T> interfaceClass, IPentahoSession curSession) throws ObjectFactoryException
Returns all objects implementing the provided interface or extending the provided class if the Class is not an Interface. The returned list will be ordered by the optional "priority" property- Parameters:
interfaceClass
- Interface or Class literal for which implementations of will be foundcurSession
- current session to be used for session-based implementations- Returns:
- List of registered implementations
- Throws:
ObjectFactoryException
-
getAll
<T> List<T> getAll(Class<T> interfaceClass, IPentahoSession curSession, Map<String,String> properties) throws ObjectFactoryException
Returns all objects implementing the provided interface or extending the provided class if the Class is not an Interface. The returned list will be ordered by the optional "priority" property- Parameters:
interfaceClass
- Interface or Class literal for which implementations of will be foundcurSession
- current session to be used for session-based implementationsproperties
- Map of properties to filter matches in the ObjectFactory by- Returns:
- List of registered implementations
- Throws:
ObjectFactoryException
-
getObjectReference
<T> IPentahoObjectReference<T> getObjectReference(Class<T> interfaceClass, IPentahoSession curSession) throws ObjectFactoryException
Returns an IPentahoObjectReference for the requested Object containing registered Object Properties.- Parameters:
interfaceClass
- Interface or Class literal for which implementations of will be foundcurSession
- current session to be used for session-based implementations- Returns:
- IPentahoObjectReference for the matching Object or null if no Object is found
- Throws:
ObjectFactoryException
-
getObjectReference
<T> IPentahoObjectReference<T> getObjectReference(Class<T> interfaceClass, IPentahoSession curSession, Map<String,String> properties) throws ObjectFactoryException
Returns an IPentahoObjectReference for the requested Object containing registered Object Properties.- Parameters:
interfaceClass
- Interface or Class literal for which implementations of will be foundcurSession
- current session to be used for session-based implementationsproperties
- Map of properties to filter matches in the ObjectFactory by- Returns:
- IPentahoObjectReference for the matching Object or null if no Object is found
- Throws:
ObjectFactoryException
-
getObjectReferences
<T> List<IPentahoObjectReference<T>> getObjectReferences(Class<T> interfaceClass, IPentahoSession curSession) throws ObjectFactoryException
Returns an IPentahoObjectReference for the requested Object containing registered Object Properties.- Parameters:
interfaceClass
- Interface or Class literal for which implementations of will be foundcurSession
- current session to be used for session-based implementations- Returns:
- IPentahoObjectReference for the matching Object or null if no Object is found
- Throws:
ObjectFactoryException
-
getObjectReferences
<T> List<IPentahoObjectReference<T>> getObjectReferences(Class<T> interfaceClass, IPentahoSession curSession, Map<String,String> properties) throws ObjectFactoryException
Returns an IPentahoObjectReference for the requested Object containing registered Object Properties.- Parameters:
interfaceClass
- Interface or Class literal for which implementations of will be foundcurSession
- current session to be used for session-based implementationsproperties
- Map of properties to filter matches in the ObjectFactory by- Returns:
- IPentahoObjectReference for the matching Object or null if no Object is found
- Throws:
ObjectFactoryException
-
getName
String getName()
Return the name for this factory. Not assumed to be unique. Useful for logging only- Returns:
- factory name
-
-