org.pentaho.test.platform.engine.core
Class SimpleObjectFactory

java.lang.Object
  extended by org.pentaho.test.platform.engine.core.SimpleObjectFactory
All Implemented Interfaces:
IPentahoObjectFactory

public class SimpleObjectFactory
extends Object
implements IPentahoObjectFactory


Constructor Summary
SimpleObjectFactory()
           
 
Method Summary
 void defineObject(String key, String classname)
          Register an object for creation.
<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, String key, IPentahoSession session)
          Retrieves an instance of a Pentaho BI Server API interface by the given object key.
 Class<?> getImplementingClass(String key)
          Provides the concrete Class defined for the given object key.
 void init(String configFile, Object context)
          Initialize the factory with optional configuration file and runtime context.
 boolean objectDefined(String key)
          Checks if the implementation for the given interface is defined.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleObjectFactory

public SimpleObjectFactory()
Method Detail

get

public <T> T get(Class<T> interfaceClass,
                 IPentahoSession session)
      throws ObjectFactoryException
Description copied from interface: IPentahoObjectFactory
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.

Specified by:
get in interface IPentahoObjectFactory
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

public <T> T get(Class<T> interfaceClass,
                 String key,
                 IPentahoSession session)
      throws ObjectFactoryException
Description copied from interface: IPentahoObjectFactory
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.

Specified by:
get in interface IPentahoObjectFactory
Parameters:
interfaceClass - the type of object to retrieve (retrieved object will be returned as this type)
key - the object identifier, typically the interface name
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

getImplementingClass

public Class<?> getImplementingClass(String key)
Description copied from interface: IPentahoObjectFactory
Provides the concrete Class defined for the given object key.

Specified by:
getImplementingClass in interface IPentahoObjectFactory
Parameters:
key - the object identifier, typically the interface name
Returns:
the type of object associated with key

init

public void init(String configFile,
                 Object context)
Description copied from interface: IPentahoObjectFactory
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.

Specified by:
init in interface IPentahoObjectFactory
Parameters:
configFile - an object configuration definition file understandable by the factory implementation
context - 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.

objectDefined

public boolean objectDefined(String key)
Description copied from interface: IPentahoObjectFactory
Checks if the implementation for the given interface is defined.

Specified by:
objectDefined in interface IPentahoObjectFactory
Parameters:
key - the object identifier, typically the interface name
Returns:
true if the object is defined

defineObject

public void defineObject(String key,
                         String classname)
Register an object for creation.

Parameters:
key - identifying string
classname - must be a fully qualified class name for a top-level or nested top-level (static inner) class