Interface StateManagerFactory

  • All Known Implementing Classes:
    StateManagerFactoryImpl

    public interface StateManagerFactory
    Factory for StateManagers. Whenever we have a persistable object that needs to be managed and the values of its fields accessed/updated we associate the object with a StateManager.

    A user can specify the persistence property datanucleus.stateManager.className to define the StateManager class to instantiate, otherwise it will instantiate either org.datanucleus.state.StateManagerImpl, or the preferred StateManager required by the particular datastore (see storeMgr.getDefaultStateManagerClassName()).

    • Method Detail

      • close

        void close()
      • disconnectStateManager

        void disconnectStateManager​(DNStateManager sm)
        Method to be called when an StateManager is disconnected (finished with). This facilitates its reuse within a pool.
        Parameters:
        sm - StateManager
      • newForHollow

        <T> DNStateManager<T> newForHollow​(ExecutionContext ec,
                                           Class<T> pcClass,
                                           Object id)
        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.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - the ExecutionContext
        pcClass - the class of the new instance to be created.
        id - the identity of the object.
        Returns:
        StateManager
      • newForHollowPreConstructed

        <T> DNStateManager<T> newForHollowPreConstructed​(ExecutionContext ec,
                                                         Object id,
                                                         T pc)
        Constructs a StateManager to manage a hollow instance having the given object ID. The instance is already supplied.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - ExecutionContext
        id - the identity of the object.
        pc - The object that is hollow that we are going to manage
        Returns:
        StateManager
      • newForHollow

        <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. This constructor is used for creating new instances of persistent objects obtained e.g. via a Query or backed by a view.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - ExecutionContext
        pcClass - 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
      • newForPersistentClean

        <T> DNStateManager<T> newForPersistentClean​(ExecutionContext ec,
                                                    Object id,
                                                    T pc)
        Constructs a StateManager to manage the specified persistent instance having the given object ID.
        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
      • newForHollowPopulatedAppId

        @Deprecated
        <T> DNStateManager<T> newForHollowPopulatedAppId​(ExecutionContext ec,
                                                         Class<T> pcClass,
                                                         FieldValues fv)
        Deprecated.
        Use newForHollowPopulated instead
        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.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - ExecutionContext
        pcClass - the class of the new instance to be created.
        fv - the initial field values of the object.
        Returns:
        StateManager
      • newForEmbedded

        <T> DNStateManager<T> newForEmbedded​(ExecutionContext ec,
                                             T pc,
                                             boolean copyPc,
                                             DNStateManager ownerSM,
                                             int ownerMemberNumber,
                                             PersistableObjectType ownerMemberCmpt)
        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.
        Type Parameters:
        T - Type of the persistable class
        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
        ownerSM - Owner StateManager
        ownerMemberNumber - Member number in owner object where this is stored
        ownerMemberCmpt - Component within the member where this is stored
        Returns:
        StateManager
      • newForEmbedded

        DNStateManager newForEmbedded​(ExecutionContext ec,
                                      AbstractClassMetaData cmd,
                                      DNStateManager ownerSM,
                                      int ownerMemberNumber,
                                      PersistableObjectType ownerMemberCmpt)
        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.
        Parameters:
        ec - ExecutionContext
        cmd - Meta-data for the class that this is an instance of.
        ownerSM - Owner StateManager
        ownerMemberNumber - Member number in owner object where this is stored
        ownerMemberCmpt - Component within the member where this is stored
        Returns:
        StateManager
      • newForPersistentNew

        <T> DNStateManager<T> newForPersistentNew​(ExecutionContext ec,
                                                  T pc,
                                                  FieldValues fv)
        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.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - ExecutionContext
        pc - the instance being make persistent.
        fv - Any changes to make before inserting
        Returns:
        StateManager
      • newForTransactionalTransient

        <T> DNStateManager<T> newForTransactionalTransient​(ExecutionContext ec,
                                                           T pc)
        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.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - ExecutionContext
        pc - the instance being make persistent.
        Returns:
        StateManager
      • newForDetached

        <T> DNStateManager<T> newForDetached​(ExecutionContext ec,
                                             T pc,
                                             Object id,
                                             Object version)
        Constructor for creating StateManager instances to manage persistable objects in detached state.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - ExecutionContext
        pc - the detached object
        id - the identity of the object.
        version - the detached version
        Returns:
        StateManager
      • newForPNewToBeDeleted

        <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. Consequently the initial lifecycle state will be P_NEW, but will soon move to P_NEW_DELETED.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - Execution Context
        pc - the object being deleted from persistence
        Returns:
        StateManager
      • newForCachedPC

        <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. Makes a copy of the cached object, assigns a StateManager to it, and copies across the fields that were loaded when cached.
        Type Parameters:
        T - Type of the persistable class
        Parameters:
        ec - ExecutionContext
        id - Id to assign to the persistable object
        cachedPC - CachedPC object from the L2 cache
        Returns:
        StateManager