org.jaffa.persistence.engines.jdbcengine.proxy
Class PersistentInstanceFactory

java.lang.Object
  extended byorg.jaffa.persistence.engines.jdbcengine.proxy.PersistentInstanceFactory

public class PersistentInstanceFactory
extends Object

This class is a factory for obtaining IPersistent instances.


Constructor Summary
PersistentInstanceFactory()
           
 
Method Summary
static Class getActualPersistentClass(IPersistent object)
          This is a helper method to determine the actual class which was used to create an IPersistent instance.
static IPersistent newPersistentInstance(Class persistentClass)
          Generates an appropriate instance for the input persistentClass.
static void setInstanceValue(IPersistent object, String attributeName, Object value)
          This is used by the MoldingService to initialize the Persistent instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistentInstanceFactory

public PersistentInstanceFactory()
Method Detail

newPersistentInstance

public static IPersistent newPersistentInstance(Class persistentClass)
Generates an appropriate instance for the input persistentClass. If the persistentClass is a 'Class', then it should implement the 'IPersistent' interface. The persistence engine will simply instantiate the class. If the persistentClass is an 'Interface', then the persistence engine will generate a dynamic proxy, to implement the IPersistent and the 'persistentClass' interfaces. A RuntimeException will be thrown if any error occurs during instantiation.

Parameters:
persistentClass - The actual persistentClass which can represent a 'Class' or an 'Interface'
Returns:
an instance implementing the IPersistent interface.

getActualPersistentClass

public static Class getActualPersistentClass(IPersistent object)
This is a helper method to determine the actual class which was used to create an IPersistent instance. It is quite possible that the input object is a dynamic proxy.

Parameters:
object - The object which implements the IPersistent instance.
Returns:
The class which was used for instantiating the instance.

setInstanceValue

public static void setInstanceValue(IPersistent object,
                                    String attributeName,
                                    Object value)
This is used by the MoldingService to initialize the Persistent instance. This will merely add the attribute/value to the Map in the PersistentInstanceInvocationHandler. This will bypass the validations performed during invocation of the setXyz() method on the persistent object. Nothing will be done if the input object is not a Proxy or if its InvocationHandler is not an instance of PersistentInstanceInvocationHandler.

Parameters:
object - The Proxy object for an IPersistence interface.
attributeName - The attribute whose value will be set.
value - The value to be set.


Copyright © 2002-2004 JAFFA Project.