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 JDOStateManager
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 JDOStateManager
instance responsible for the state transitions of the instance as well as managing the contents of the fields of the instance. The JDOStateManager
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 JDOStateManager
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 theStateManager
of the owning First Class Object of the change.
-
-
Field Summary
Fields Modifier and Type Field Description static byte
LOAD_REQUIRED
static byte
READ_OK
static byte
READ_WRITE_OK
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addDependency(StateManager sm)
Adds another StateManager to this StateManager dependencies list.void
applyUpdates(String fieldName, SCOCollection c)
...void
commit(boolean retainValues)
...void
copyFields(StateManager source)
Copies field values fromsource
to this StateManager's fields.void
deletePersistent()
...void
flushed()
...Object
getHiddenValue(int index)
Returns value for a hidden field.void
getLock()
Lock this instance.Object
getObjectId()
...PersistenceConfig
getPersistenceConfig()
...PersistenceManager
getPersistenceManager()
...PersistenceManager
getPersistenceManagerInternal()
...Object
getPersistent()
get actualImage associated with thisStateManager
boolean
getPresenceMaskBit(int index)
Returns true if field with this index is present in the instance.boolean
hasVersionConsistency()
Returns true, if the managed instance has Version Consistency.void
initialize(boolean persistentInDB)
State initializationboolean
isDeleted()
...boolean
isDirty()
boolean
isNew()
...boolean
isPersistent()
...boolean
isProcessed()
...boolean
isTransactional()
...boolean
isValid()
Returns true if this StateManager is valid for use.boolean
isVerificationFailed()
Returns, if this state manager has failed version consistency validation.void
loadForRead()
...void
loadForUpdate()
...void
makeDirty(String fieldName)
...void
makePersistent(PersistenceManager pm, Object pc)
ThePersistenceManager
needs to call this method in order to make an instance persistent.void
makePresent(String fieldName, Object value)
...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.void
markReplacement()
Notifies the StateManager that this instance is a replacement for a deleted instance with the same ObjectId.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.boolean
needsRegisterWithVersionConsistencyCache()
boolean
needsUpdateInVersionConsistencyCache()
void
prepareGetField(int fieldID)
void
prepareToUpdatePhaseI()
void
prepareToUpdatePhaseII(HashSet phase3sms)
This is the second phase of the commit processing.void
prepareToUpdatePhaseIII()
This is the third phase of commit processing.void
refreshPersistent()
...void
release()
Release references in the StateManager to the persistent instance, ObjectId, and PersistenceManager.void
releaseLock()
Release this instance.void
reload()
Reload the instance associated with this StateManager.void
replaceObjectField(String fieldName, Object o)
...void
resolveDependencies()
Tries to resolve the dependencies for all instances waiting for the current state manager to be flushed to the store.void
rollback(boolean retainValues)
...boolean[]
setBooleanArrayField(int fieldNumber, boolean[] value)
boolean
setBooleanField(int fieldNumber, boolean value)
byte[]
setByteArrayField(int fieldNumber, byte[] value)
byte
setByteField(int fieldNumber, byte value)
char
setCharArrayField(int fieldNumber, char value)
char
setCharField(int fieldNumber, char value)
double[]
setDoubleArrayField(int fieldNumber, double[] value)
double
setDoubleField(int fieldNumber, double value)
byte
setFlags(byte flags)
...float[]
setFloatArrayField(int fieldNumber, float[] value)
float
setFloatField(int fieldNumber, float value)
void
setHiddenValue(int index, Object value)
Sets value for a hidden field.int[]
setIntArrayField(int fieldNumber, int[] value)
int
setIntField(int fieldNumber, int value)
long[]
setLongArrayField(int fieldNumber, long[] value)
long
setLongField(int fieldNumber, long value)
Object[]
setObjectArrayField(int fieldNumber, Object[] value)
Object
setObjectField(int fieldNumber, Object value)
void
setObjectId(Object objectId)
...void
setPersistenceManager(PersistenceManager pm)
...void
setPersistent(Object obj)
set actualImage associated with thisStateManager
void
setPresenceMaskBit(int index)
Marks field with this index as present.short[]
setShortArrayField(int fieldNumber, short[] value)
short
setShortField(int fieldNumber, short value)
String[]
setStringArrayField(int fieldNumber, String[] value)
String
setStringField(int fieldNumber, String value)
void
setValid()
Mark this StateManager as valid.void
setVerificationFailed()
Marks that this state manager has failed version consistency validation.void
updatePersistent(StateManager next)
...boolean
verifyPersistent()
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)
ThePersistenceManager
needs to call this method in order to make an instance persistent.
-
deletePersistent
void deletePersistent()
... ThePersistenceManager
calls this method to delete a persistent instance.
-
updatePersistent
void updatePersistent(StateManager next)
... ThePersistenceManager
calls this method to flush changes made to theStateManager
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()
... ThePersistenceManager
calls this method to refresh the state of theStateManager
from the database.
-
commit
void commit(boolean retainValues)
... ThePersistenceManager
calls this method to inform theStateManager
that the transaction has been committed.
-
rollback
void rollback(boolean retainValues)
... ThePersistenceManager
calls this method to inform theStateManager
that the transaction has been rolled back.
-
flushed
void flushed()
... ThePersistenceManager
calls this method to inform theStateManager
that the flush processing is completed.
-
isProcessed
boolean isProcessed()
... ThePersistenceManager
calls 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. Thevalid
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.
-
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 fromsource
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.
-
-