org.datanucleus.state
Class StateManagerFactory

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

public class StateManagerFactory
extends java.lang.Object

Factory of StateManagers.

Version:
$Revision: 1.27 $

Nested Class Summary
protected static class StateManagerFactory.Initialization
           
 
Field Summary
protected static Localiser LOCALISER
          Localiser for messages.
 
Constructor Summary
StateManagerFactory()
           
 
Method Summary
static StateManager newStateManagerForCachedPC(ObjectManager om, java.lang.Object id, CachedPC cachedPC)
          Constructor to create a StateManager for an object taken from the L2 cache with the specified id.
static StateManager newStateManagerForDetached(ObjectManager om, java.lang.Object pc, java.lang.Object id, java.lang.Object version)
          Constructor for creating SM instances to manage persistable objects in detached state.
static StateManager newStateManagerForEmbedded(ObjectManager om, java.lang.Object pc, boolean copyPc)
          Constructs a state manager to manage a persistable instance that will be EMBEDDED/SERIALISED into another persistable object.
static StateManager newStateManagerForHollow(ObjectManager om, java.lang.Class pcClass, java.lang.Object id)
          Constructs a state manager to manage a hollow instance having the given object ID.
static StateManager newStateManagerForHollowPopulated(ObjectManager om, java.lang.Class pcClass, java.lang.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.
static StateManager newStateManagerForHollowPopulatedAppId(ObjectManager om, java.lang.Class pcClass, FieldValues fv)
          Constructs a state manager to manage a hollow (or pclean) instance having the given FieldValues.
static StateManager newStateManagerForHollowPreConstructed(ObjectManager om, java.lang.Object id, java.lang.Object pc)
          Constructs a state manager to manage a hollow instance having the given object ID.
static StateManager newStateManagerForPersistentClean(ObjectManager om, java.lang.Object id, java.lang.Object pc)
          Constructs a state manager to manage the specified persistent instance having the given object ID.
static StateManager newStateManagerForPersistentNew(ObjectManager om, java.lang.Object pc, FieldValues preInsertChanges)
          Constructs a state manager to manage a transient instance that is becoming newly persistent.
static StateManager newStateManagerForPNewToBeDeleted(ObjectManager om, java.lang.Object pc)
          Constructor for creating SM instances to manage persistable objects that are not persistent yet are about to be deleted.
static StateManager newStateManagerForTransactionalTransient(ObjectManager om, java.lang.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

newStateManagerForHollow

public static StateManager newStateManagerForHollow(ObjectManager om,
                                                    java.lang.Class pcClass,
                                                    java.lang.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:
om - the persistence manager controlling this state manager.
pcClass - the class of the new instance to be created.
id - the JDO identity of the object.

newStateManagerForHollowPreConstructed

public static StateManager newStateManagerForHollowPreConstructed(ObjectManager om,
                                                                  java.lang.Object id,
                                                                  java.lang.Object pc)
Constructs a state manager to manage a hollow instance having the given object ID. The instance is already supplied.

Parameters:
om - the persistence manager controlling this state manager.
id - the JDO identity of the object.
pc - The object that is hollow that we are going to manage

newStateManagerForHollowPopulated

public static StateManager newStateManagerForHollowPopulated(ObjectManager om,
                                                             java.lang.Class pcClass,
                                                             java.lang.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:
om - the object manager controlling this state manager.
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.

newStateManagerForPersistentClean

public static StateManager newStateManagerForPersistentClean(ObjectManager om,
                                                             java.lang.Object id,
                                                             java.lang.Object pc)
Constructs a state manager to manage the specified persistent instance having the given object ID.

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

newStateManagerForHollowPopulatedAppId

public static StateManager newStateManagerForHollowPopulatedAppId(ObjectManager om,
                                                                  java.lang.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:
om - the object manager controlling this state manager.
pcClass - the class of the new instance to be created.
fv - the initial field values of the object.

newStateManagerForEmbedded

public static StateManager newStateManagerForEmbedded(ObjectManager om,
                                                      java.lang.Object pc,
                                                      boolean copyPc)
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:
om - The object manager controlling this state manager.
pc - The persistable to manage (see copyPc also)
copyPc - Whether the SM should manage a copy of the passed PC or that one

newStateManagerForPersistentNew

public static StateManager newStateManagerForPersistentNew(ObjectManager om,
                                                           java.lang.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:
om - the object manager controlling this state manager.
pc - the instance being make persistent.
preInsertChanges - Any changes to make before inserting

newStateManagerForTransactionalTransient

public static StateManager newStateManagerForTransactionalTransient(ObjectManager om,
                                                                    java.lang.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:
om - the object manager controlling this state manager.
pc - the instance being make persistent.

newStateManagerForDetached

public static StateManager newStateManagerForDetached(ObjectManager om,
                                                      java.lang.Object pc,
                                                      java.lang.Object id,
                                                      java.lang.Object version)
Constructor for creating SM instances to manage persistable objects in detached state.

Parameters:
om - ObjectManager
pc - the detached object
id - the JDO identity of the object.
version - the detached version
Since:
1.1

newStateManagerForPNewToBeDeleted

public static StateManager newStateManagerForPNewToBeDeleted(ObjectManager om,
                                                             java.lang.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:
om - ObjectManager
pc - the object being deleted from persistence
Since:
1.2

newStateManagerForCachedPC

public static StateManager newStateManagerForCachedPC(ObjectManager om,
                                                      java.lang.Object id,
                                                      CachedPC cachedPC)
Constructor to create a StateManager for an object taken from the L2 cache with the specified id. Makes a copy of the cached object, assigns a StateManager to it, and copies across the fields that were loaded when cached.

Parameters:
om - Object Manager managing this object
id - Id to assign to the persistable object
cachedPC - CachedPC object from the L2 cache


Copyright © 2009. All Rights Reserved.