- java.lang.Object
-
- org.datanucleus.state.StateManagerFactoryImpl
-
- All Implemented Interfaces:
StateManagerFactory
public class StateManagerFactoryImpl extends Object implements StateManagerFactory
Factory for StateManagers.
-
-
Field Summary
Fields Modifier and Type Field Description static Class[]
STATE_MANAGER_CTR_ARG_CLASSES
-
Constructor Summary
Constructors Constructor Description StateManagerFactoryImpl(PersistenceNucleusContext nucCtx)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
void
disconnectStateManager(DNStateManager sm)
Method to be called when an StateManager is disconnected (finished with).protected DNStateManager
getStateManager(ExecutionContext ec, AbstractClassMetaData cmd)
<T> DNStateManager<T>
newForCachedPC(ExecutionContext ec, Object id, CachedPC cachedPC)
Constructor to create a StateManager for an object taken from the L2 cache with the specified id.<T> DNStateManager<T>
newForDetached(ExecutionContext ec, T pc, Object id, Object version)
Constructor for creating StateManager instances to manage persistable objects in detached state.DNStateManager
newForEmbedded(ExecutionContext ec, AbstractClassMetaData cmd, DNStateManager ownerSM, int ownerMemberNumber, PersistableObjectType objectType)
Constructs a StateManager 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.<T> DNStateManager<T>
newForEmbedded(ExecutionContext ec, T pc, boolean copyPc, DNStateManager ownerSM, int ownerMemberNumber, PersistableObjectType objectType)
Constructs a StateManager to manage a persistable instance that will be EMBEDDED/SERIALISED into another persistable object.<T> DNStateManager<T>
newForHollow(ExecutionContext ec, Class<T> pcClass, Object id)
Constructs a StateManager to manage a hollow instance having the given object ID.<T> DNStateManager<T>
newForHollow(ExecutionContext ec, Class<T> pcClass, Object id, FieldValues fv)
Constructs a StateManager to manage a recently populated hollow instance having the given object ID and the given field values.<T> DNStateManager<T>
newForHollowPopulatedAppId(ExecutionContext ec, Class<T> pcClass, FieldValues fv)
Deprecated.<T> DNStateManager<T>
newForHollowPreConstructed(ExecutionContext ec, Object id, T pc)
Constructs a StateManager to manage a hollow instance having the given object ID.<T> DNStateManager<T>
newForPersistentClean(ExecutionContext ec, Object id, T pc)
Constructs a StateManager to manage the specified persistent instance having the given object ID.<T> DNStateManager<T>
newForPersistentNew(ExecutionContext ec, T pc, FieldValues preInsertChanges)
Constructs a StateManager to manage a transient instance that is becoming newly persistent.<T> DNStateManager<T>
newForPNewToBeDeleted(ExecutionContext ec, T pc)
Constructor for creating StateManager instances to manage persistable objects that are not persistent yet are about to be deleted.<T> DNStateManager<T>
newForTransactionalTransient(ExecutionContext ec, T pc)
Constructs a StateManager to manage a transactional-transient instance.
-
-
-
Field Detail
-
STATE_MANAGER_CTR_ARG_CLASSES
public static final Class[] STATE_MANAGER_CTR_ARG_CLASSES
-
-
Constructor Detail
-
StateManagerFactoryImpl
public StateManagerFactoryImpl(PersistenceNucleusContext nucCtx)
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceStateManagerFactory
-
newForHollow
public <T> DNStateManager<T> newForHollow(ExecutionContext ec, Class<T> pcClass, Object id)
Description copied from interface:StateManagerFactory
Constructs a StateManager to manage a hollow instance having the given object ID. This constructor is used for creating new instances of existing persistent objects.- Specified by:
newForHollow
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- the ExecutionContextpcClass
- the class of the new instance to be created.id
- the identity of the object.- Returns:
- StateManager
-
newForHollow
public <T> DNStateManager<T> newForHollow(ExecutionContext ec, Class<T> pcClass, Object id, FieldValues fv)
Description copied from interface:StateManagerFactory
Constructs a StateManager 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.- Specified by:
newForHollow
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- ExecutionContextpcClass
- the class of the new instance to be created.id
- the identity of the object.fv
- the initial field values of the object.- Returns:
- StateManager
-
newForHollowPreConstructed
public <T> DNStateManager<T> newForHollowPreConstructed(ExecutionContext ec, Object id, T pc)
Description copied from interface:StateManagerFactory
Constructs a StateManager to manage a hollow instance having the given object ID. The instance is already supplied.- Specified by:
newForHollowPreConstructed
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- ExecutionContextid
- the identity of the object.pc
- The object that is hollow that we are going to manage- Returns:
- StateManager
-
newForHollowPopulatedAppId
@Deprecated public <T> DNStateManager<T> newForHollowPopulatedAppId(ExecutionContext ec, Class<T> pcClass, FieldValues fv)
Deprecated.Description copied from interface:StateManagerFactory
Constructs a StateManager 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.- Specified by:
newForHollowPopulatedAppId
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- ExecutionContextpcClass
- the class of the new instance to be created.fv
- the initial field values of the object.- Returns:
- StateManager
-
newForPersistentClean
public <T> DNStateManager<T> newForPersistentClean(ExecutionContext ec, Object id, T pc)
Description copied from interface:StateManagerFactory
Constructs a StateManager to manage the specified persistent instance having the given object ID.- Specified by:
newForPersistentClean
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- the execution context controlling this state manager.id
- the identity of the object.pc
- The object that is persistent that we are going to manage- Returns:
- StateManager
-
newForEmbedded
public <T> DNStateManager<T> newForEmbedded(ExecutionContext ec, T pc, boolean copyPc, DNStateManager ownerSM, int ownerMemberNumber, PersistableObjectType objectType)
Description copied from interface:StateManagerFactory
Constructs a StateManager 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.- Specified by:
newForEmbedded
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- ExecutionContextpc
- The persistable to manage (see copyPc also)copyPc
- Whether the SM should manage a copy of the passed PC or that oneownerSM
- Owner StateManagerownerMemberNumber
- Member number in owner object where this is storedobjectType
- Component within the member where this is stored- Returns:
- StateManager
-
newForEmbedded
public DNStateManager newForEmbedded(ExecutionContext ec, AbstractClassMetaData cmd, DNStateManager ownerSM, int ownerMemberNumber, PersistableObjectType objectType)
Description copied from interface:StateManagerFactory
Constructs a StateManager 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.- Specified by:
newForEmbedded
in interfaceStateManagerFactory
- Parameters:
ec
- ExecutionContextcmd
- Meta-data for the class that this is an instance of.ownerSM
- Owner StateManagerownerMemberNumber
- Member number in owner object where this is storedobjectType
- Component within the member where this is stored- Returns:
- StateManager
-
newForPersistentNew
public <T> DNStateManager<T> newForPersistentNew(ExecutionContext ec, T pc, FieldValues preInsertChanges)
Description copied from interface:StateManagerFactory
Constructs a StateManager 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.- Specified by:
newForPersistentNew
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- ExecutionContextpc
- the instance being make persistent.preInsertChanges
- Any changes to make before inserting- Returns:
- StateManager
-
newForTransactionalTransient
public <T> DNStateManager<T> newForTransactionalTransient(ExecutionContext ec, T pc)
Description copied from interface:StateManagerFactory
Constructs a StateManager 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.- Specified by:
newForTransactionalTransient
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- ExecutionContextpc
- the instance being make persistent.- Returns:
- StateManager
-
newForDetached
public <T> DNStateManager<T> newForDetached(ExecutionContext ec, T pc, Object id, Object version)
Description copied from interface:StateManagerFactory
Constructor for creating StateManager instances to manage persistable objects in detached state.- Specified by:
newForDetached
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- ExecutionContextpc
- the detached objectid
- the identity of the object.version
- the detached version- Returns:
- StateManager
-
newForPNewToBeDeleted
public <T> DNStateManager<T> newForPNewToBeDeleted(ExecutionContext ec, T pc)
Description copied from interface:StateManagerFactory
Constructor for creating StateManager 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.- Specified by:
newForPNewToBeDeleted
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- Execution Contextpc
- the object being deleted from persistence- Returns:
- StateManager
-
newForCachedPC
public <T> DNStateManager<T> newForCachedPC(ExecutionContext ec, Object id, CachedPC cachedPC)
Description copied from interface:StateManagerFactory
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.- Specified by:
newForCachedPC
in interfaceStateManagerFactory
- Type Parameters:
T
- Type of the persistable class- Parameters:
ec
- ExecutionContextid
- Id to assign to the persistable objectcachedPC
- CachedPC object from the L2 cache- Returns:
- StateManager
-
disconnectStateManager
public void disconnectStateManager(DNStateManager sm)
Description copied from interface:StateManagerFactory
Method to be called when an StateManager is disconnected (finished with). This facilitates its reuse within a pool.- Specified by:
disconnectStateManager
in interfaceStateManagerFactory
- Parameters:
sm
- StateManager
-
getStateManager
protected DNStateManager getStateManager(ExecutionContext ec, AbstractClassMetaData cmd)
-
-