Interface StateManager

  • All Known Implementing Classes:
    SQLStateManager

    public interface StateManager
    An object that manages the state transitions and the contents of the fields of a JDO Instance. If a JDO Instance is persistent or transactional, it contains a non-null reference to a JDO StateManager instance which is responsible for managing the JDO Instance state changes and for interfacing with the JDO PersistenceManager. Additionally, Persistent JDO Instances refers to an instance of the JDO StateManager instance responsible for the state transitions of the instance as well as managing the contents of the fields of the instance. The JDO StateManager interface is the primary interface used by the JDO Instance to mediate life cycle changes. Non-transient JDO Instances always contain a non-null reference to an associated JDO StateManager instance. When a First Class Object is instantiated in the JVM, the JDO implementation assigns to fields with a Tracked Second Class Object type a new instance that tracks changes made to itself, and notifies the StateManager of the owning First Class Object of the change.
    • Method Detail

      • makePersistent

        void makePersistent​(PersistenceManager pm,
                            Object pc)
        The PersistenceManager needs to call this method in order to make an instance persistent.
      • deletePersistent

        void deletePersistent()
        ... The PersistenceManager calls this method to delete a persistent instance.
      • updatePersistent

        void updatePersistent​(StateManager next)
        ... The PersistenceManager calls this method to flush changes made to the StateManager to the database. The specified StateManager argument is used to determine whether the actual instance should be flushed immediately or whether batch update is possible.
      • refreshPersistent

        void refreshPersistent()
        ... The PersistenceManager calls this method to refresh the state of the StateManager from the database.
      • commit

        void commit​(boolean retainValues)
        ... The PersistenceManager calls this method to inform the StateManager that the transaction has been committed.
      • rollback

        void rollback​(boolean retainValues)
        ... The PersistenceManager calls this method to inform the StateManager that the transaction has been rolled back.
      • flushed

        void flushed()
        ... The PersistenceManager calls this method to inform the StateManager that the flush processing is completed.
      • isProcessed

        boolean isProcessed()
        ... The PersistenceManager calls this method to verify that corresponding object has been flushed to the database
      • setPersistent

        void setPersistent​(Object obj)
        set actualImage associated with this StateManager
      • getPersistent

        Object getPersistent()
        get actualImage associated with this StateManager
      • setObjectId

        void setObjectId​(Object objectId)
        ...
      • getObjectId

        Object getObjectId()
        ...
      • initialize

        void initialize​(boolean persistentInDB)
        State initialization
        Parameters:
        persistentInDB - true if object is persistent in DB
      • makePresent

        void makePresent​(String fieldName,
                         Object value)
        ...
      • makeDirty

        void makeDirty​(String fieldName)
        ...
      • replaceObjectField

        void replaceObjectField​(String fieldName,
                                Object o)
        ...
      • prepareToUpdatePhaseI

        void prepareToUpdatePhaseI()
      • prepareToUpdatePhaseII

        void prepareToUpdatePhaseII​(HashSet phase3sms)
        This is the second phase of the commit processing. It populates phase3sms with all the autopersistence instances that are no longer reachable from a persistent instance.
      • prepareToUpdatePhaseIII

        void prepareToUpdatePhaseIII()
        This is the third phase of commit processing. It sets up the delete dependencies among all the autopersistent instances that have been flushed to the database.
      • setFlags

        byte setFlags​(byte flags)
        ...
      • loadForRead

        void loadForRead()
        ...
      • loadForUpdate

        void loadForUpdate()
        ...
      • isDirty

        boolean isDirty()
      • isTransactional

        boolean isTransactional()
        ...
      • isNew

        boolean isNew()
        ...
      • isDeleted

        boolean isDeleted()
        ...
      • isPersistent

        boolean isPersistent()
        ...
      • needsRegisterWithVersionConsistencyCache

        boolean needsRegisterWithVersionConsistencyCache()
        Returns:
        True, if this instance is persistent, transactional, not new, not dirty, and not deleted; false otherwise.
      • needsUpdateInVersionConsistencyCache

        boolean needsUpdateInVersionConsistencyCache()
        Returns:
        True, if this instance should be synchronized with the version consistency cache; false otherwise.
      • prepareGetField

        void prepareGetField​(int fieldID)
      • setBooleanField

        boolean setBooleanField​(int fieldNumber,
                                boolean value)
      • setBooleanArrayField

        boolean[] setBooleanArrayField​(int fieldNumber,
                                       boolean[] value)
      • setByteField

        byte setByteField​(int fieldNumber,
                          byte value)
      • setByteArrayField

        byte[] setByteArrayField​(int fieldNumber,
                                 byte[] value)
      • setShortField

        short setShortField​(int fieldNumber,
                            short value)
      • setShortArrayField

        short[] setShortArrayField​(int fieldNumber,
                                   short[] value)
      • setIntField

        int setIntField​(int fieldNumber,
                        int value)
      • setIntArrayField

        int[] setIntArrayField​(int fieldNumber,
                               int[] value)
      • setLongField

        long setLongField​(int fieldNumber,
                          long value)
      • setLongArrayField

        long[] setLongArrayField​(int fieldNumber,
                                 long[] value)
      • setCharField

        char setCharField​(int fieldNumber,
                          char value)
      • setCharArrayField

        char setCharArrayField​(int fieldNumber,
                               char value)
      • setFloatField

        float setFloatField​(int fieldNumber,
                            float value)
      • setFloatArrayField

        float[] setFloatArrayField​(int fieldNumber,
                                   float[] value)
      • setDoubleField

        double setDoubleField​(int fieldNumber,
                              double value)
      • setDoubleArrayField

        double[] setDoubleArrayField​(int fieldNumber,
                                     double[] value)
      • setStringField

        String setStringField​(int fieldNumber,
                              String value)
      • setStringArrayField

        String[] setStringArrayField​(int fieldNumber,
                                     String[] value)
      • setObjectField

        Object setObjectField​(int fieldNumber,
                              Object value)
      • setObjectArrayField

        Object[] setObjectArrayField​(int fieldNumber,
                                     Object[] value)
      • getLock

        void getLock()
        Lock this instance. This method must be called the same number of times as #releaseLock().
      • releaseLock

        void releaseLock()
        Release this instance. This method must be called the same number of times as #getLock().
      • getHiddenValue

        Object getHiddenValue​(int index)
        Returns value for a hidden field. This method expects index to be negative for hidden fields.
        Parameters:
        index - - the hidden field index.
      • setHiddenValue

        void setHiddenValue​(int index,
                            Object value)
        Sets value for a hidden field. This method expects index to be negative for hidden fields.
        Parameters:
        index - - the hidden field index.
        value - - new value.
      • setPresenceMaskBit

        void setPresenceMaskBit​(int index)
        Marks field with this index as present.
        Parameters:
        index - - the field number.
      • getPresenceMaskBit

        boolean getPresenceMaskBit​(int index)
        Returns true if field with this index is present in the instance.
      • markNotRegistered

        void markNotRegistered()
        Notifies the StateManager that this instance needs to be registered with the global (weak) cache at rollback if it transitions to persistent state. Used for replacing a deleted instance with the newly persistent with the same object id.
      • markVerifyAtDeregister

        void markVerifyAtDeregister()
        Notifies the StateManager that this instance needs to be verified at the time it is removed from the global (weak) cache at rollback if it transitions to transient state.
      • addDependency

        void addDependency​(StateManager sm)
        Adds another StateManager to this StateManager dependencies list.
        Parameters:
        sm - the StateManager to add.
      • resolveDependencies

        void resolveDependencies()
        Tries to resolve the dependencies for all instances waiting for the current state manager to be flushed to the store.
      • markReplacement

        void markReplacement()
        Notifies the StateManager that this instance is a replacement for a deleted instance with the same ObjectId.
      • release

        void release()
        Release references in the StateManager to the persistent instance, ObjectId, and PersistenceManager.
      • isValid

        boolean isValid()
        Returns true if this StateManager is valid for use. The valid flag is initially set to false and changed to true when the first operation (e.g. makePersistent(), loadForRead(), or PersistenceManager.getObjectById()) succeeds.
      • setValid

        void setValid()
        Mark this StateManager as valid. Called before returning from getObjectById. Flag is set to true internally in the StateManager at makePersistent(), or initialize(true) (to be used for storing query or navigation results.
      • hasVersionConsistency

        boolean hasVersionConsistency()
        Returns true, if the managed instance has Version Consistency.
        Returns:
        True, if the managed object has Version Consistency.
      • copyFields

        void copyFields​(StateManager source)
        Copies field values from source to this StateManager's fields.
        Parameters:
        source - StateManager from which field values are copied into this instance.
      • verifyPersistent

        boolean verifyPersistent()
        Verify that an instance set up with Version consistency is not modified in a parallel transaction.
        Returns:
        false if the instance is persistent clean and modified by a parallel transaction, true otherwise.
      • setVerificationFailed

        void setVerificationFailed()
        Marks that this state manager has failed version consistency validation.
      • isVerificationFailed

        boolean isVerificationFailed()
        Returns, if this state manager has failed version consistency validation.
        Returns:
        True, if this state manager is marked as failed.