org.pentaho.platform.engine.core.system.objfac
Class AbstractSpringPentahoObjectFactory

java.lang.Object
  extended by org.pentaho.platform.engine.core.system.objfac.AbstractSpringPentahoObjectFactory
All Implemented Interfaces:
IPentahoObjectFactory
Direct Known Subclasses:
StandaloneSpringPentahoObjectFactory, WebSpringPentahoObjectFactory

public abstract class AbstractSpringPentahoObjectFactory
extends Object
implements IPentahoObjectFactory

Framework for Spring-based object factories. Subclasses are required only to implement the init method, which is responsible for setting the ApplicationContext.

A note on creation and management of objects: Object creation and scoping is handled by Spring with one exception: in the case of a StandaloneSession. Spring's session scope relates a bean to an HttpSession, and as such it does not know about custom sessions. The correct approach to solve this problem is to write a custom Spring scope (called something like "pentahosession"). Unfortunately, we cannot implement a custom scope to handle the StandaloneSession because the custom scope would not be able to access it. There is currently no way to statically obtain a reference to a pentaho session. So we are left with using custom logic in this factory to execute a different non-Spring logic path when the IPentahoSession is of type StandaloneSession.

TODO (BISERVER-2380) remove the custom logic in retreiveObject(String, IPentahoSession) and use a custom Spring scope to handle any session types that Spring does not handle out-of-the-box, such as StandaloneSession. In order to do this, we need a way to access the current IPentahoSession from a static context (perhaps a ThreadLocal).

Author:
Aaron Phillips
See Also:
IPentahoObjectFactory

Constructor Summary
AbstractSpringPentahoObjectFactory()
           
 
Method Summary
<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.
 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
 
Methods inherited from interface org.pentaho.platform.api.engine.IPentahoObjectFactory
init
 

Constructor Detail

AbstractSpringPentahoObjectFactory

public AbstractSpringPentahoObjectFactory()
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
See Also:
IPentahoObjectFactory.get(Class, IPentahoSession)

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
See Also:
IPentahoObjectFactory.get(Class, String, IPentahoSession)

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
See Also:
IPentahoObjectFactory.objectDefined(String)

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
See Also:
IPentahoObjectFactory.getImplementingClass(String)