A transaction records all objects accessed during the lifetime
of the transaction in this record (queries and created).
This information, stored on a per-object basis within the
ObjectTracker, covers the database engine used
to persist the object, the object's OID, the object itself, and
whether the object has been deleted in this transaction,
created in this transaction.
Sidenote: Objects identified as read only are not updated
when the transaction commits.
allObjectStates
public String allObjectStates()
clear
public void clear()
Reset ObjectTracker's state.
getMolderForObject
public ClassMolder getMolderForObject(Object o)
Retrieve the ClassMolder associated with a specific object.
o
- Object instance the associated ClassMolder should be retrieved.
- The ClassMolder instance associated with the Object instance specified.
getOIDForObject
public OID getOIDForObject(Object o)
getObjectForOID
public Object getObjectForOID(LockEngine engine,
OID oid,
boolean allowReadOnly)
Retrieve the object for a given OID.
engine
- Lock engine mapped to oidoid
- Object id specifiedallowReadOnly
- Allow (or ignore, if false) read-only objects to be returned.
- The object associated with this oid.
getObjectsWithCreatingStateSortedByLowestMolderPriority
public Collection getObjectsWithCreatingStateSortedByLowestMolderPriority()
Retrieve the list of 'creating' objects (to be created), sorted in the
order they should be created.
- List of objects to be created, sorted in the order they should
be created.
getObjectsWithDeletedStateSortedByHighestMolderPriority
public Collection getObjectsWithDeletedStateSortedByHighestMolderPriority()
Retrieve the list of 'deleted' objects, sorted in the order they should be
deleted.
- List of 'deleted' objects, sorted in the order they should be
deleted.
getObjectsWithUpdateCacheNeededState
public Collection getObjectsWithUpdateCacheNeededState()
getReadOnlyObjects
public Collection getReadOnlyObjects()
Retrieve the list of all read-only objects being tracked.
- List of all read-only objects being currently tracked
getReadWriteObjects
public Collection getReadWriteObjects()
Retrieve the list of all read-write objects being tracked.
- List of all read-write objects being currently tracked.
isCreated
public boolean isCreated(Object o)
isCreating
public boolean isCreating(Object o)
isDeleted
public boolean isDeleted(Object o)
isReadOnly
public boolean isReadOnly(Object o)
isReadWrite
public boolean isReadWrite(Object object)
Returns true if the specified object is tracked as a read-write object.
object
- Object instance for which it should be determined whether
it's tracked as read-write object
- True if the specified object is tracked as a read-write object
isTracking
public boolean isTracking(Object object)
Determine whether an object is being tracked within this tracking manager.
object
- The object for which it should be determined whether it is tracked.
- True if the object specified is tracked; false otherwise
isUpdateCacheNeeded
public boolean isUpdateCacheNeeded(Object object)
Returns true if the cache needs to be updated for the given object.
object
- An object instance
- true if the cache needs to be updated; false, otherwise.
isUpdatePersistNeeded
public boolean isUpdatePersistNeeded(Object object)
Returns true if the given object needs to be written to the persistence store.
object
- An object instance
- true if the object needs to be written to the persistence store
markCreated
public void markCreated(Object object)
markDeleted
public void markDeleted(Object object)
markReadOnly
public void markReadOnly(Object o)
markUpdateCacheNeeded
public void markUpdateCacheNeeded(Object object)
markUpdatePersistNeeded
public void markUpdatePersistNeeded(Object object)
objectStateToString
public String objectStateToString(Object obj)
Returns the object's state.
obj
- Object for which its state should be output.
- The state of the object specified
readOnlySize
public int readOnlySize()
readWriteSize
public int readWriteSize()
removeOIDForObject
public void removeOIDForObject(LockEngine engine,
OID oid)
For a given lockengine and OID, remove references to an object in the maps.
This eliminates both the engine->oid->object and the object->oid.
engine
- The engine to stop tracking the OID foroid
- The oid of the object to stop tracking on.
setOIDForObject
public void setOIDForObject(Object obj,
LockEngine engine,
OID oid)
For a given lockengine and OID, set the object in the maps. Note that an OID
can only be accessed via the LockManager which manages it.
obj
- The object to trackengine
- The engine to which the OID belongsoid
- The OID of the object to track
trackOIDChange
public void trackOIDChange(Object obj,
LockEngine engine,
OID oldoid,
OID newoid)
Record changes to an OID by re-tracking the OID information. When an object's
OID can change, ensure that the object is retracked.
obj
- The object to record a tracking change for.engine
- The engine which is responsible for the old and new OIDoldoid
- The old oid.newoid
- The new oid.
trackObject
public void trackObject(ClassMolder molder,
OID oid,
Object object)
unmarkAllDeleted
public void unmarkAllDeleted()
unmarkDeleted
public void unmarkDeleted(Object object)
unmarkReadOnly
public void unmarkReadOnly(Object o)
unmarkUpdateCacheNeeded
public void unmarkUpdateCacheNeeded(Object object)
unmarkUpdatePersistNeeded
public void unmarkUpdatePersistNeeded(Object object)
untrackObject
public void untrackObject(Object object)