Interface StateManager
-
- All Known Implementing Classes:
SQLStateManager
public interface StateManagerAn 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 JDOStateManagerinstance 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 JDOStateManagerinstance responsible for the state transitions of the instance as well as managing the contents of the fields of the instance. The JDOStateManagerinterface 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 JDOStateManagerinstance. 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 theStateManagerof the owning First Class Object of the change.
-
-
Field Summary
Fields Modifier and Type Field Description static byteLOAD_REQUIREDstatic byteREAD_OKstatic byteREAD_WRITE_OK
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddDependency(StateManager sm)Adds another StateManager to this StateManager dependencies list.voidapplyUpdates(String fieldName, SCOCollection c)...voidcommit(boolean retainValues)...voidcopyFields(StateManager source)Copies field values fromsourceto this StateManager's fields.voiddeletePersistent()...voidflushed()...ObjectgetHiddenValue(int index)Returns value for a hidden field.voidgetLock()Lock this instance.ObjectgetObjectId()...PersistenceConfiggetPersistenceConfig()...PersistenceManagergetPersistenceManager()...PersistenceManagergetPersistenceManagerInternal()...ObjectgetPersistent()get actualImage associated with thisStateManagerbooleangetPresenceMaskBit(int index)Returns true if field with this index is present in the instance.booleanhasVersionConsistency()Returns true, if the managed instance has Version Consistency.voidinitialize(boolean persistentInDB)State initializationbooleanisDeleted()...booleanisDirty()booleanisNew()...booleanisPersistent()...booleanisProcessed()...booleanisTransactional()...booleanisValid()Returns true if this StateManager is valid for use.booleanisVerificationFailed()Returns, if this state manager has failed version consistency validation.voidloadForRead()...voidloadForUpdate()...voidmakeDirty(String fieldName)...voidmakePersistent(PersistenceManager pm, Object pc)ThePersistenceManagerneeds to call this method in order to make an instance persistent.voidmakePresent(String fieldName, Object value)...voidmarkNotRegistered()Notifies the StateManager that this instance needs to be registered with the global (weak) cache at rollback if it transitions to persistent state.voidmarkReplacement()Notifies the StateManager that this instance is a replacement for a deleted instance with the same ObjectId.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.booleanneedsRegisterWithVersionConsistencyCache()booleanneedsUpdateInVersionConsistencyCache()voidprepareGetField(int fieldID)voidprepareToUpdatePhaseI()voidprepareToUpdatePhaseII(HashSet phase3sms)This is the second phase of the commit processing.voidprepareToUpdatePhaseIII()This is the third phase of commit processing.voidrefreshPersistent()...voidrelease()Release references in the StateManager to the persistent instance, ObjectId, and PersistenceManager.voidreleaseLock()Release this instance.voidreload()Reload the instance associated with this StateManager.voidreplaceObjectField(String fieldName, Object o)...voidresolveDependencies()Tries to resolve the dependencies for all instances waiting for the current state manager to be flushed to the store.voidrollback(boolean retainValues)...boolean[]setBooleanArrayField(int fieldNumber, boolean[] value)booleansetBooleanField(int fieldNumber, boolean value)byte[]setByteArrayField(int fieldNumber, byte[] value)bytesetByteField(int fieldNumber, byte value)charsetCharArrayField(int fieldNumber, char value)charsetCharField(int fieldNumber, char value)double[]setDoubleArrayField(int fieldNumber, double[] value)doublesetDoubleField(int fieldNumber, double value)bytesetFlags(byte flags)...float[]setFloatArrayField(int fieldNumber, float[] value)floatsetFloatField(int fieldNumber, float value)voidsetHiddenValue(int index, Object value)Sets value for a hidden field.int[]setIntArrayField(int fieldNumber, int[] value)intsetIntField(int fieldNumber, int value)long[]setLongArrayField(int fieldNumber, long[] value)longsetLongField(int fieldNumber, long value)Object[]setObjectArrayField(int fieldNumber, Object[] value)ObjectsetObjectField(int fieldNumber, Object value)voidsetObjectId(Object objectId)...voidsetPersistenceManager(PersistenceManager pm)...voidsetPersistent(Object obj)set actualImage associated with thisStateManagervoidsetPresenceMaskBit(int index)Marks field with this index as present.short[]setShortArrayField(int fieldNumber, short[] value)shortsetShortField(int fieldNumber, short value)String[]setStringArrayField(int fieldNumber, String[] value)StringsetStringField(int fieldNumber, String value)voidsetValid()Mark this StateManager as valid.voidsetVerificationFailed()Marks that this state manager has failed version consistency validation.voidupdatePersistent(StateManager next)...booleanverifyPersistent()Verify that an instance set up with Version consistency is not modified in a parallel transaction.
-
-
-
Field Detail
-
LOAD_REQUIRED
static final byte LOAD_REQUIRED
- See Also:
- Constant Field Values
-
READ_OK
static final byte READ_OK
- See Also:
- Constant Field Values
-
READ_WRITE_OK
static final byte READ_WRITE_OK
- See Also:
- Constant Field Values
-
-
Method Detail
-
makePersistent
void makePersistent(PersistenceManager pm, Object pc)
ThePersistenceManagerneeds to call this method in order to make an instance persistent.
-
deletePersistent
void deletePersistent()
... ThePersistenceManagercalls this method to delete a persistent instance.
-
updatePersistent
void updatePersistent(StateManager next)
... ThePersistenceManagercalls this method to flush changes made to theStateManagerto 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()
... ThePersistenceManagercalls this method to refresh the state of theStateManagerfrom the database.
-
commit
void commit(boolean retainValues)
... ThePersistenceManagercalls this method to inform theStateManagerthat the transaction has been committed.
-
rollback
void rollback(boolean retainValues)
... ThePersistenceManagercalls this method to inform theStateManagerthat the transaction has been rolled back.
-
flushed
void flushed()
... ThePersistenceManagercalls this method to inform theStateManagerthat the flush processing is completed.
-
isProcessed
boolean isProcessed()
... ThePersistenceManagercalls this method to verify that corresponding object has been flushed to the database
-
setPersistenceManager
void setPersistenceManager(PersistenceManager pm)
...
-
getPersistenceManager
PersistenceManager getPersistenceManager()
...
-
getPersistenceManagerInternal
PersistenceManager getPersistenceManagerInternal()
...
-
setPersistent
void setPersistent(Object obj)
set actualImage associated with thisStateManager
-
getPersistent
Object getPersistent()
get actualImage associated with thisStateManager
-
setObjectId
void setObjectId(Object objectId)
...
-
getObjectId
Object getObjectId()
...
-
getPersistenceConfig
PersistenceConfig getPersistenceConfig()
...
-
initialize
void initialize(boolean persistentInDB)
State initialization- Parameters:
persistentInDB- true if object is persistent in DB
-
makeDirty
void makeDirty(String fieldName)
...
-
applyUpdates
void applyUpdates(String fieldName, SCOCollection c)
...
-
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)
-
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. Thevalidflag 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.
-
reload
void reload()
Reload the instance associated with this StateManager. Called byPersistenceManager.getObjectById(Object, boolean)with validate flag set totrue
-
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 fromsourceto 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.
-
-