org.datanucleus.state
Class StateManagerFactory

java.lang.Object
  extended by org.datanucleus.state.StateManagerFactory

public class StateManagerFactory
extends Object

Factory for ObjectProviders of type StateManager. These are used when using bytecode enhancement in the persistent objects, and so setting/getting values using the bytecode enhancement contract.


Nested Class Summary
protected static class StateManagerFactory.Initialization
          Convenience process to get class and associated meta-data for the StateManager.
 
Field Summary
protected static Localiser LOCALISER
          Localiser for messages.
 
Constructor Summary
StateManagerFactory()
           
 
Method Summary
 ObjectProvider newForCachedPC(ExecutionContext ec, Object id, CachedPC cachedPC)
          Constructor to create a ObjectProvider for an object taken from the L2 cache with the specified id.
 ObjectProvider newForDetached(ExecutionContext ec, Object pc, Object id, Object version)
          Constructor for creating SM instances to manage persistable objects in detached state.
 ObjectProvider newForEmbedded(ExecutionContext ec, AbstractClassMetaData cmd, ObjectProvider ownerOP, int ownerFieldNumber)
          Constructs a state manager for an object of the specified type, creating the PC object to hold the values where this object will be EMBEDDED/SERIALISED into another persistable object.
 ObjectProvider newForEmbedded(ExecutionContext ec, Object pc, boolean copyPc, ObjectProvider ownerOP, int ownerFieldNumber)
          Constructs a state manager to manage a persistable instance that will be EMBEDDED/SERIALISED into another persistable object.
 ObjectProvider newForHollow(ExecutionContext ec, Class pcClass, Object id)
          Constructs a state manager to manage a hollow instance having the given object ID.
 ObjectProvider newForHollowPopulated(ExecutionContext ec, Class pcClass, Object id, FieldValues fv)
          Constructs a state manager to manage a recently populated hollow instance having the given object ID and the given field values.
 ObjectProvider newForHollowPopulatedAppId(ExecutionContext ec, Class pcClass, FieldValues fv)
          Constructs a state manager to manage a hollow (or pclean) instance having the given FieldValues.
 ObjectProvider newForHollowPreConstructed(ExecutionContext ec, Object id, Object pc)
          Constructs a state manager to manage a hollow instance having the given object ID.
 ObjectProvider newForPersistentClean(ExecutionContext ec, Object id, Object pc)
          Constructs a state manager to manage the specified persistent instance having the given object ID.
 ObjectProvider newForPersistentNew(ExecutionContext ec, Object pc, FieldValues preInsertChanges)
          Constructs a state manager to manage a transient instance that is becoming newly persistent.
 ObjectProvider newForPNewToBeDeleted(ExecutionContext ec, Object pc)
          Constructor for creating SM instances to manage persistable objects that are not persistent yet are about to be deleted.
 ObjectProvider newForTransactionalTransient(ExecutionContext ec, Object pc)
          Constructs a state manager to manage a Transactional Transient instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localiser for messages.

Constructor Detail

StateManagerFactory

public StateManagerFactory()
Method Detail

newForHollow

public ObjectProvider newForHollow(ExecutionContext ec,
                                   Class pcClass,
                                   Object id)
Constructs a state manager to manage a hollow instance having the given object ID. This constructor is used for creating new instances of existing persistent objects.

Parameters:
ec - the ExecutionContext
pcClass - the class of the new instance to be created.
id - the JDO identity of the object.

newForHollowPreConstructed

public ObjectProvider newForHollowPreConstructed(ExecutionContext ec,
                                                 Object id,
                                                 Object pc)
Constructs a state manager to manage a hollow instance having the given object ID. The instance is already supplied.

Parameters:
ec - ExecutionContext
id - the JDO identity of the object.
pc - The object that is hollow that we are going to manage

newForHollowPopulated

public ObjectProvider newForHollowPopulated(ExecutionContext ec,
                                            Class pcClass,
                                            Object id,
                                            FieldValues fv)
Constructs a state manager to manage a recently populated hollow instance having the given object ID and the given field values. This constructor is used for creating new instances of persistent objects obtained e.g. via a Query or backed by a view.

Parameters:
ec - ExecutionContext
pcClass - the class of the new instance to be created.
id - the JDO identity of the object.
fv - the initial field values of the object.

newForPersistentClean

public ObjectProvider newForPersistentClean(ExecutionContext ec,
                                            Object id,
                                            Object pc)
Constructs a state manager to manage the specified persistent instance having the given object ID.

Parameters:
ec - the execution context controlling this state manager.
id - the JDO identity of the object.
pc - The object that is persistent that we are going to manage

newForHollowPopulatedAppId

public ObjectProvider newForHollowPopulatedAppId(ExecutionContext ec,
                                                 Class pcClass,
                                                 FieldValues fv)
Constructs a state manager to manage a hollow (or pclean) instance having the given FieldValues. This constructor is used for creating new instances of existing persistent objects using application identity.

Parameters:
ec - ExecutionContext
pcClass - the class of the new instance to be created.
fv - the initial field values of the object.

newForEmbedded

public ObjectProvider newForEmbedded(ExecutionContext ec,
                                     Object pc,
                                     boolean copyPc,
                                     ObjectProvider ownerOP,
                                     int ownerFieldNumber)
Constructs a state manager to manage a persistable instance that will be EMBEDDED/SERIALISED into another persistable object. The instance will not be assigned an identity in the process since it is a SCO.

Parameters:
ec - ExecutionContext
pc - The persistable to manage (see copyPc also)
copyPc - Whether the SM should manage a copy of the passed PC or that one
ownerOP - Owner ObjectProvider
ownerFieldNumber - Field number in owner object where this is stored

newForEmbedded

public ObjectProvider newForEmbedded(ExecutionContext ec,
                                     AbstractClassMetaData cmd,
                                     ObjectProvider ownerOP,
                                     int ownerFieldNumber)
Constructs a state manager for an object of the specified type, creating the PC object to hold the values where this object will be EMBEDDED/SERIALISED into another persistable object. The instance will not be assigned an identity in the process since it is a SCO.

Parameters:
ec - ExecutionContext
cmd - Meta-data for the class that this is an instance of.
ownerOP - Owner ObjectProvider
ownerFieldNumber - Field number in owner object where this is stored

newForPersistentNew

public ObjectProvider newForPersistentNew(ExecutionContext ec,
                                          Object pc,
                                          FieldValues preInsertChanges)
Constructs a state manager to manage a transient instance that is becoming newly persistent. A new object ID for the instance is obtained from the store manager and the object is inserted in the data store. This constructor is used for assigning state managers to existing instances that are transitioning to a persistent state.

Parameters:
ec - ExecutionContext
pc - the instance being make persistent.
preInsertChanges - Any changes to make before inserting

newForTransactionalTransient

public ObjectProvider newForTransactionalTransient(ExecutionContext ec,
                                                   Object pc)
Constructs a state manager to manage a Transactional Transient instance. A new object ID for the instance is obtained from the store manager and the object is inserted in the data store. This constructor is used for assigning state managers to Transient instances that are transitioning to a transient clean state.

Parameters:
ec - ExecutionContext
pc - the instance being make persistent.

newForDetached

public ObjectProvider newForDetached(ExecutionContext ec,
                                     Object pc,
                                     Object id,
                                     Object version)
Constructor for creating SM instances to manage persistable objects in detached state.

Parameters:
ec - ExecutionContext
pc - the detached object
id - the JDO identity of the object.
version - the detached version

newForPNewToBeDeleted

public ObjectProvider newForPNewToBeDeleted(ExecutionContext ec,
                                            Object pc)
Constructor for creating SM instances to manage persistable objects that are not persistent yet are about to be deleted. Consequently the initial lifecycle state will be P_NEW, but will soon move to P_NEW_DELETED.

Parameters:
ec - Execution Context
pc - the object being deleted from persistence

newForCachedPC

public ObjectProvider newForCachedPC(ExecutionContext ec,
                                     Object id,
                                     CachedPC cachedPC)
Constructor to create a ObjectProvider for an object taken from the L2 cache with the specified id. Makes a copy of the cached object, assigns a ObjectProvider to it, and copies across the fields that were loaded when cached.

Parameters:
ec - ExecutionContext
id - Id to assign to the persistable object
cachedPC - CachedPC object from the L2 cache


Copyright © 2012. All Rights Reserved.