FileDocCategorySizeDatePackage
StateManager.javaAPI DocGlassfish v2 API14745Fri May 04 22:34:58 BST 2007com.sun.jdo.spi.persistence.support.sqlstore

StateManager

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.

Fields Summary
static final byte
LOAD_REQUIRED
static final byte
READ_OK
static final byte
READ_WRITE_OK
Constructors Summary
Methods Summary
public voidaddDependency(com.sun.jdo.spi.persistence.support.sqlstore.StateManager sm)
Adds another StateManager to this StateManager dependencies list.

param
sm the StateManager to add.

public voidapplyUpdates(java.lang.String fieldName, SCOCollection c)
...

public voidcommit(boolean retainValues)
... The PersistenceManager calls this method to inform the StateManager that the transaction has been committed.

public voidcopyFields(com.sun.jdo.spi.persistence.support.sqlstore.StateManager source)
Copies field values from source to this StateManager's fields.

param
source StateManager from which field values are copied into this instance.

public voiddeletePersistent()
... The PersistenceManager calls this method to delete a persistent instance.

public voidflushed()
... The PersistenceManager calls this method to inform the StateManager that the flush processing is completed.

public java.lang.ObjectgetHiddenValue(int index)
Returns value for a hidden field. This method expects index to be negative for hidden fields.

param
index - the hidden field index.

public voidgetLock()
Lock this instance. This method must be called the same number of times as #releaseLock().

public java.lang.ObjectgetObjectId()
...

public PersistenceConfiggetPersistenceConfig()
...

public com.sun.jdo.api.persistence.support.PersistenceManagergetPersistenceManager()
...

public com.sun.jdo.api.persistence.support.PersistenceManagergetPersistenceManagerInternal()
...

public java.lang.ObjectgetPersistent()
get actualImage associated with this StateManager

public booleangetPresenceMaskBit(int index)
Returns true if field with this index is present in the instance.

public booleanhasVersionConsistency()
Returns true, if the managed instance has Version Consistency.

return
True, if the managed object has Version Consistency.

public voidinitialize(boolean persistentInDB)
State initialization

param
persistentInDB true if object is persistent in DB

public booleanisDeleted()
...

public booleanisDirty()

public booleanisNew()
...

public booleanisPersistent()
...

public booleanisProcessed()
... The PersistenceManager calls this method to verify that corresponding object has been flushed to the database

public booleanisTransactional()
...

public booleanisValid()
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.

public booleanisVerificationFailed()
Returns, if this state manager has failed version consistency validation.

return
True, if this state manager is marked as failed.

public voidloadForRead()
...

public voidloadForUpdate()
...

public voidmakeDirty(java.lang.String fieldName)
...

public voidmakePersistent(PersistenceManager pm, java.lang.Object pc)
The PersistenceManager needs to call this method in order to make an instance persistent.

public voidmakePresent(java.lang.String fieldName, java.lang.Object value)
...

public voidmarkNotRegistered()
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.

public voidmarkReplacement()
Notifies the StateManager that this instance is a replacement for a deleted instance with the same ObjectId.

public voidmarkVerifyAtDeregister()
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.

public booleanneedsRegisterWithVersionConsistencyCache()

return
True, if this instance is persistent, transactional, not new, not dirty, and not deleted; false otherwise.

public booleanneedsUpdateInVersionConsistencyCache()

return
True, if this instance should be synchronized with the version consistency cache; false otherwise.

public voidprepareGetField(int fieldID)

public voidprepareToUpdatePhaseI()

public voidprepareToUpdatePhaseII(java.util.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.

public voidprepareToUpdatePhaseIII()
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.

public voidrefreshPersistent()
... The PersistenceManager calls this method to refresh the state of the StateManager from the database.

public voidrelease()
Release references in the StateManager to the persistent instance, ObjectId, and PersistenceManager.

public voidreleaseLock()
Release this instance. This method must be called the same number of times as #getLock().

public voidreload()
Reload the instance associated with this StateManager. Called by {@link PersistenceManager#getObjectById(Object, boolean) PersistenceManager.getObjectById(Object, boolean)} with validate flag set to true

public voidreplaceObjectField(java.lang.String fieldName, java.lang.Object o)
...

public voidresolveDependencies()
Tries to resolve the dependencies for all instances waiting for the current state manager to be flushed to the store.

public voidrollback(boolean retainValues)
... The PersistenceManager calls this method to inform the StateManager that the transaction has been rolled back.

public boolean[]setBooleanArrayField(int fieldNumber, boolean[] value)

public booleansetBooleanField(int fieldNumber, boolean value)

public byte[]setByteArrayField(int fieldNumber, byte[] value)

public bytesetByteField(int fieldNumber, byte value)

public charsetCharArrayField(int fieldNumber, char value)

public charsetCharField(int fieldNumber, char value)

public double[]setDoubleArrayField(int fieldNumber, double[] value)

public doublesetDoubleField(int fieldNumber, double value)

public bytesetFlags(byte flags)
...

public float[]setFloatArrayField(int fieldNumber, float[] value)

public floatsetFloatField(int fieldNumber, float value)

public voidsetHiddenValue(int index, java.lang.Object value)
Sets value for a hidden field. This method expects index to be negative for hidden fields.

param
index - the hidden field index.
param
value - new value.

public int[]setIntArrayField(int fieldNumber, int[] value)

public intsetIntField(int fieldNumber, int value)

public long[]setLongArrayField(int fieldNumber, long[] value)

public longsetLongField(int fieldNumber, long value)

public java.lang.Object[]setObjectArrayField(int fieldNumber, java.lang.Object[] value)

public java.lang.ObjectsetObjectField(int fieldNumber, java.lang.Object value)

public voidsetObjectId(java.lang.Object objectId)
...

public voidsetPersistenceManager(com.sun.jdo.api.persistence.support.PersistenceManager pm)
...

public voidsetPersistent(java.lang.Object obj)
set actualImage associated with this StateManager

public voidsetPresenceMaskBit(int index)
Marks field with this index as present.

param
index - the field number.

public short[]setShortArrayField(int fieldNumber, short[] value)

public shortsetShortField(int fieldNumber, short value)

public java.lang.String[]setStringArrayField(int fieldNumber, java.lang.String[] value)

public java.lang.StringsetStringField(int fieldNumber, java.lang.String value)

public voidsetValid()
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.

public voidsetVerificationFailed()
Marks that this state manager has failed version consistency validation.

public voidupdatePersistent(com.sun.jdo.spi.persistence.support.sqlstore.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.

public booleanverifyPersistent()
Verify that an instance set up with Version consistency is not modified in a parallel transaction.

return
false if the instance is persistent clean and modified by a parallel transaction, true otherwise.