public abstract class AbstractStateManager extends Object implements ObjectProvider
Modifier and Type | Field and Description |
---|---|
protected ActivityState |
activity
state for transitions of activities.
|
protected AbstractClassMetaData |
cmd
the metadata for the class.
|
protected FieldManager |
currFM
Current FieldManager.
|
protected boolean |
dirty
Indicator for whether the persistable instance is dirty.
|
protected boolean[] |
dirtyFields
indicators for which fields are currently dirty in the persistable instance.
|
protected static int |
FLAG_ATTACHING
Flag for
flags whether we are in the process of attaching the object. |
protected static int |
FLAG_BECOMING_DELETED |
protected static int |
FLAG_CHANGING_STATE |
protected static int |
FLAG_DETACHING
Flag for
flags whether we are in the process of detaching the object. |
protected static int |
FLAG_DISCONNECTING
Flag for
flags whether we are in the process of disconnecting the object. |
protected static int |
FLAG_FLUSHED_NEW
if the persistable object is new and was flushed to the datastore.
|
protected static int |
FLAG_FLUSHING
Flag for
flags whether we are in the process of flushing changes to the object. |
protected static int |
FLAG_LOADINGFPFIELDS |
protected static int |
FLAG_MAKING_TRANSIENT
Flag for
flags whether we are in the process of making transient the object. |
protected static int |
FLAG_NEED_INHERITANCE_VALIDATION
Whether the managed object needs the inheritance level validating before loading fields.
|
protected static int |
FLAG_POSTINSERT_UPDATE |
protected static int |
FLAG_POSTLOAD_PENDING |
protected static int |
FLAG_RESETTING_DETACHED_STATE
Flag for
flags whether we are resetting the detached state. |
protected static int |
FLAG_RETRIEVING_DETACHED_STATE
Flag for
flags whether we are retrieving detached state from the detached object. |
protected static int |
FLAG_STORING_PC
Flag to signify that we are currently storing the persistable object, so we don't detach it on serialisation.
|
protected static int |
FLAG_UPDATING_EMBEDDING_FIELDS_WITH_OWNER
Flag whether this SM is updating the ownership of its embedded/serialised field(s).
|
protected int |
flags
Bit-packed flags for operational settings (packed into "int" for memory benefit).
|
protected static SingleTypeFieldManager |
HOLLOWFIELDMANAGER |
protected boolean[] |
loadedFields
indicators for which fields are currently loaded in the persistable instance.
|
protected static Localiser |
LOCALISER |
protected Lock |
lock
Lock object to synchronise execution when reading/writing fields.
|
protected short |
lockMode
The current lock mode for this object.
|
protected ExecutionContext |
myEC
The ExecutionContext for this StateManager
|
protected FetchPlanForClass |
myFP
Fetch plan for the class of the managed object.
|
protected Object |
myID
The object identity in the datastore
|
protected Object |
myInternalID
The object identity in the JVM.
|
protected LifeCycleState |
myLC
The actual LifeCycleState for the persistable instance
|
protected Object |
myVersion
version field for optimistic transactions
|
protected short |
objectType
The type of the managed object (0 = PC, 1 = embedded PC, 2 = embedded element, 3 = embedded key, 4 = embedded value.
|
static HashMap<String,ObjectValueGenerator> |
objectValGenerators
Cache of object-value-generators, keyed by their symbolic name.
|
protected byte |
persistenceFlags
Flags for state stored with the object.
|
protected boolean |
restoreValues
Whether to restore values at StateManager.
|
protected byte |
savedFlags
Flags of the PersistenceCapable instance when the instance is enlisted in the transaction.
|
protected boolean[] |
savedLoadedFields
Loaded fields of the PersistenceCapable instance when the instance is enlisted in the transaction.
|
protected Object |
transactionalVersion
version field for optimistic transactions, after a insert/update but not yet committed.
|
EMBEDDED_COLLECTION_ELEMENT_PC, EMBEDDED_MAP_KEY_PC, EMBEDDED_MAP_VALUE_PC, EMBEDDED_PC, ORIGINAL_FIELD_VALUE_KEY_PREFIX, PC
Constructor and Description |
---|
AbstractStateManager(ExecutionContext ec,
AbstractClassMetaData cmd)
Constructor for object of specified type managed by the provided ExecutionContext.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
areFieldsLoaded(int[] fieldNumbers)
Accessor for whether all of the specified field numbers are loaded.
|
boolean |
becomingDeleted()
Whether this object is moving to a deleted state.
|
protected void |
clearDirtyFlags()
Method to clear all dirty flags on the object.
|
protected void |
clearDirtyFlags(int[] fieldNumbers)
Method to clear all dirty flags on the object.
|
protected void |
clearFieldsByNumbers(int[] fieldNumbers) |
void |
connect(ExecutionContext ec,
AbstractClassMetaData cmd)
Method to (re)connect the provider to the specified ExecutionContext and object type.
|
boolean |
containsAssociatedValue(Object key) |
void |
evict()
Method to change the object state to evicted.
|
boolean |
getAllFieldsLoaded()
Returns whether all fields are loaded.
|
Object |
getAssociatedValue(Object key)
Accessor for an associated value stored with this object.
|
protected CallbackHandler |
getCallbackHandler()
returns the handler for callback events.
|
AbstractClassMetaData |
getClassMetaData()
Accessor for the ClassMetaData for this object.
|
String[] |
getDirtyFieldNames()
Convenience accessor for the names of the fields that are dirty.
|
int[] |
getDirtyFieldNumbers()
Accessor for the field numbers of all dirty fields.
|
boolean[] |
getDirtyFields()
Creates a copy of the
dirtyFields bitmap. |
ExecutionContext |
getExecutionContext()
Accessor for the ExecutionContext for this object.
|
protected int[] |
getFieldNumbersOfLoadedOrDirtyFields(boolean[] loadedFields,
boolean[] dirtyFields)
Convenience accessor to return the field numbers for the input loaded and dirty field arrays.
|
Object |
getInternalObjectId()
Accessor for the internal object id of the object we are managing.
|
LifeCycleState |
getLifecycleState()
Accessor for the LifeCycleState
|
String[] |
getLoadedFieldNames()
Convenience accessor for the names of the fields that are loaded.
|
int[] |
getLoadedFieldNumbers()
Accessor for the field numbers of all loaded fields in this managed instance.
|
boolean[] |
getLoadedFields()
Accessor for the fields
|
short |
getLockMode()
Accessor for the current lock mode.
|
abstract Object |
getObject()
Accessor for the persistable object being managed.
|
String |
getObjectAsPrintable()
Returns a printable form of the managed object.
|
protected static ObjectValueGenerator |
getObjectValueGenerator(ExecutionContext ec,
String genName)
Method to find an object value generator based on its name.
|
Object |
getTransactionalVersion(Object pc)
Return the object representing the transactional version of the calling instance.
|
protected void |
internalDeletePersistent()
Method to delete the object from the datastore.
|
boolean |
isAttaching() |
protected boolean |
isChangingState() |
boolean |
isDeleting()
Tests whether this object is in the process of being deleted.
|
boolean |
isDetaching() |
protected boolean |
isDisconnecting() |
boolean |
isEmbedded()
Convenience accessor for whether this StateManager manages an embedded/serialised object.
|
boolean |
isFieldLoaded(int fieldNumber)
Accessor for whether a field is currently loaded.
|
boolean |
isFlushedNew()
Whether this record has been flushed to the datastore in this transaction (i.e called persist() and is in
the datastore now).
|
boolean |
isFlushedToDatastore()
Accessor for whether all changes have been written to the datastore.
|
protected boolean |
isFlushing() |
boolean |
isInserting()
Tests whether this object is being inserted.
|
protected boolean |
isMakingTransient() |
protected boolean |
isPostLoadPending() |
protected boolean |
isResettingDetachedState() |
boolean |
isRestoreValues()
Accessor for whether we are in the process of restoring the values.
|
protected boolean |
isRetrievingDetachedState() |
protected boolean |
isStoringPC() |
boolean |
isWaitingToBeFlushedToDatastore()
Accessor for whether the instance is newly persistent yet hasnt yet been flushed to the datastore.
|
void |
loadFieldFromDatastore(int fieldNumber)
Convenience method to load a field from the datastore.
|
protected void |
loadFieldsFromDatastore(int[] fieldNumbers)
Convenience method to load fields from the datastore.
|
protected int[] |
loadFieldsFromLevel2Cache(int[] fieldNumbers)
Convenience method to retrieve field values from an L2 cached object if they are loaded in that object.
|
void |
loadFieldsInFetchPlan(FetchPlanState state)
Method to load all unloaded fields in the FetchPlan.
|
void |
locate()
Locate the object in the datastore.
|
void |
lock(short lockMode)
Method to lock the object owned by this ObjectProvider.
|
void |
makeNontransactional()
Method to change the object state to nontransactional.
|
void |
makePersistentTransactionalTransient()
Makes Transactional Transient instances persistent.
|
void |
markAsFlushed()
Method to notify the object provider that the object has now been flushed to the datastore.
|
void |
markForInheritanceValidation()
Mark the state manager as needing to validate the inheritance of the managed object existence
before loading fields.
|
protected void |
markPKFieldsAsLoaded()
Convenience method to mark PK fields as loaded (if using app id).
|
void |
postCommit(Transaction tx)
This method is invoked just after a commit is performed in a Transaction
involving the persistable object managed by this StateManager
|
protected abstract void |
postStateChange()
Method called after a change in state.
|
void |
preBegin(Transaction tx)
Method invoked just before a transaction starts for the ExecutionContext managing us.
|
void |
preRollback(Transaction tx)
This method is invoked just before a rollback is performed in a Transaction
involving the persistable object managed by this StateManager.
|
protected void |
preStateChange()
Method called before a change in state.
|
abstract void |
provideFields(int[] fieldNumbers,
FieldManager fm)
Called from the StoreManager after StoreManager.update() is called to obtain updated values
from the PersistenceCapable associated with this StateManager.
|
void |
refresh()
Method to refresh the object.
|
void |
removeAssociatedValue(Object key)
Method to remove the associated value with the specified key (if it exists).
|
abstract void |
replaceFields(int[] fieldNumbers,
FieldManager fm)
Called from the StoreManager to refresh data in the persistable object associated with this StateManager.
|
void |
retrieve(boolean fgOnly)
Method to retrieve the object.
|
void |
setAssociatedValue(Object key,
Object value)
Method to set an associated value stored with this object.
|
void |
setFlushedNew(boolean flag) |
void |
setFlushing(boolean flushing) |
void |
setPcObjectType(short objType)
Method to set this StateManager as managing an embedded/serialised object.
|
void |
setStoringPC()
Method to set the storing PC flag.
|
void |
setTransactionalVersion(Object version)
Sets the value for the version column in a transaction not yet committed
|
void |
setVersion(Object version)
Sets the value for the version column in the datastore
|
String |
toString() |
protected void |
transitionReadField(boolean isLoaded)
Method to change the object state to read-field.
|
protected void |
transitionWriteField()
Method to change the object state to write-field.
|
void |
unloadField(String fieldName)
Convenience method to unload a field/property.
|
void |
unloadNonFetchPlanFields()
Method that will unload all fields that are not in the FetchPlan.
|
void |
unlock()
Method to unlock the object owned by this ObjectProvider (if locked).
|
void |
unsetStoringPC()
Method to unset the storing PC flag.
|
protected void |
updateLevel2CacheForFields(int[] fieldNumbers)
Convenience method to update a Level2 cached version of this object if cacheable
and has not been modified during this transaction.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
attach, attach, attachCopy, changeActivityState, checkInheritance, clearFields, clearLoadedFlags, clearNonPrimaryKeyFields, clearSavedFields, copyFieldsFromObject, deletePersistent, detach, detachCopy, disconnect, enlistInTransaction, evictFromTransaction, flush, getEmbeddedOwners, getExternalObjectId, getReferencedPC, getTransactionalVersion, getVersion, initialiseForCachedPC, initialiseForDetached, initialiseForEmbedded, initialiseForHollow, initialiseForHollowAppId, initialiseForHollowPreConstructed, initialiseForPersistentClean, initialiseForPersistentNew, initialiseForPNewToBeDeleted, initialiseForTransactionalTransient, isLoaded, loadField, loadFieldValues, loadUnloadedFields, loadUnloadedFieldsInFetchPlan, loadUnloadedFieldsOfClassInFetchPlan, makeDirty, makePersistent, makeTransactional, makeTransient, nullifyFields, provideField, refreshFieldsInFetchPlan, refreshLoadedFields, registerTransactional, replaceAllLoadedSCOFieldsWithValues, replaceAllLoadedSCOFieldsWithWrappers, replaceField, replaceFieldMakeDirty, replaceFields, replaceFieldValue, replaceManagedPC, replaceNonLoadedFields, resetDetachState, restoreFields, retrieveDetachState, runReachability, saveFields, setPostStoreNewObjectId, unwrapSCOField, updateFieldAfterInsert, validate, wrapSCOField
protected static final Localiser LOCALISER
protected static final SingleTypeFieldManager HOLLOWFIELDMANAGER
protected static final int FLAG_STORING_PC
protected static final int FLAG_NEED_INHERITANCE_VALIDATION
protected static final int FLAG_POSTINSERT_UPDATE
protected static final int FLAG_LOADINGFPFIELDS
protected static final int FLAG_POSTLOAD_PENDING
protected static final int FLAG_CHANGING_STATE
protected static final int FLAG_FLUSHED_NEW
protected static final int FLAG_BECOMING_DELETED
protected static final int FLAG_UPDATING_EMBEDDING_FIELDS_WITH_OWNER
protected static final int FLAG_RETRIEVING_DETACHED_STATE
flags
whether we are retrieving detached state from the detached object.protected static final int FLAG_RESETTING_DETACHED_STATE
flags
whether we are resetting the detached state.protected static final int FLAG_ATTACHING
flags
whether we are in the process of attaching the object.protected static final int FLAG_DETACHING
flags
whether we are in the process of detaching the object.protected static final int FLAG_MAKING_TRANSIENT
flags
whether we are in the process of making transient the object.protected static final int FLAG_FLUSHING
flags
whether we are in the process of flushing changes to the object.protected static final int FLAG_DISCONNECTING
flags
whether we are in the process of disconnecting the object.protected int flags
protected boolean restoreValues
protected ExecutionContext myEC
protected AbstractClassMetaData cmd
protected Object myInternalID
protected Object myID
protected LifeCycleState myLC
protected Object myVersion
protected Object transactionalVersion
protected byte persistenceFlags
protected FetchPlanForClass myFP
protected boolean dirty
protected boolean[] dirtyFields
protected boolean[] loadedFields
protected Lock lock
protected short lockMode
protected byte savedFlags
protected boolean[] savedLoadedFields
protected ActivityState activity
protected FieldManager currFM
protected short objectType
public static final HashMap<String,ObjectValueGenerator> objectValGenerators
public AbstractStateManager(ExecutionContext ec, AbstractClassMetaData cmd)
ec
- ExecutionContextcmd
- the metadata for the class.public void connect(ExecutionContext ec, AbstractClassMetaData cmd)
connect
in interface ObjectProvider
public AbstractClassMetaData getClassMetaData()
getClassMetaData
in interface ObjectProvider
public ExecutionContext getExecutionContext()
getExecutionContext
in interface ObjectProvider
public LifeCycleState getLifecycleState()
getLifecycleState
in interface ObjectProvider
protected CallbackHandler getCallbackHandler()
public abstract Object getObject()
getObject
in interface ObjectProvider
public String getObjectAsPrintable()
ObjectProvider
getObjectAsPrintable
in interface ObjectProvider
public Object getInternalObjectId()
getInternalObjectId
in interface ObjectProvider
public boolean isInserting()
isInserting
in interface ObjectProvider
public boolean isWaitingToBeFlushedToDatastore()
isWaitingToBeFlushedToDatastore
in interface ObjectProvider
public boolean isRestoreValues()
isRestoreValues
in interface ObjectProvider
public void setStoringPC()
ObjectProvider
setStoringPC
in interface ObjectProvider
public void unsetStoringPC()
ObjectProvider
unsetStoringPC
in interface ObjectProvider
protected boolean isStoringPC()
protected boolean isPostLoadPending()
protected boolean isChangingState()
protected boolean isResettingDetachedState()
protected boolean isRetrievingDetachedState()
protected boolean isDisconnecting()
protected boolean isMakingTransient()
public boolean isDeleting()
ObjectProvider
isDeleting
in interface ObjectProvider
public boolean becomingDeleted()
ObjectProvider
becomingDeleted
in interface ObjectProvider
public void markForInheritanceValidation()
ObjectProvider
markForInheritanceValidation
in interface ObjectProvider
public boolean isDetaching()
public boolean isAttaching()
public void setTransactionalVersion(Object version)
setTransactionalVersion
in interface ObjectProvider
version
- The versionpublic Object getTransactionalVersion(Object pc)
pc
- the calling persistable instancepublic void setVersion(Object version)
setVersion
in interface ObjectProvider
version
- The versionpublic void setFlushedNew(boolean flag)
setFlushedNew
in interface ObjectProvider
public boolean isFlushedNew()
ObjectProvider
isFlushedNew
in interface ObjectProvider
public boolean isFlushedToDatastore()
ObjectProvider
isFlushedToDatastore
in interface ObjectProvider
public void setFlushing(boolean flushing)
setFlushing
in interface ObjectProvider
protected boolean isFlushing()
public void markAsFlushed()
ObjectProvider
markAsFlushed
in interface ObjectProvider
protected void preStateChange()
protected abstract void postStateChange()
public void refresh()
refresh
in interface ObjectProvider
public void retrieve(boolean fgOnly)
retrieve
in interface ObjectProvider
fgOnly
- Only load the current fetch group fieldspublic void makePersistentTransactionalTransient()
makePersistentTransactionalTransient
in interface ObjectProvider
public void makeNontransactional()
makeNontransactional
in interface ObjectProvider
protected void transitionReadField(boolean isLoaded)
isLoaded
- if the field was previously loadedprotected void transitionWriteField()
public void evict()
evict
in interface ObjectProvider
public void preBegin(Transaction tx)
preBegin
in interface ObjectProvider
tx
- The transactionpublic void postCommit(Transaction tx)
postCommit
in interface ObjectProvider
tx
- The transactionpublic void preRollback(Transaction tx)
preRollback
in interface ObjectProvider
tx
- The transactionprotected void internalDeletePersistent()
public void locate()
locate
in interface ObjectProvider
NucleusObjectNotFoundException
- if the object doesnt exist.public abstract void provideFields(int[] fieldNumbers, FieldManager fm)
provideFields
in interface ObjectProvider
fieldNumbers
- An array of field numbers to be updated by the Storefm
- The updated values are stored in this object. This object is only valid
for the duration of this call.public abstract void replaceFields(int[] fieldNumbers, FieldManager fm)
replaceFields
in interface ObjectProvider
fieldNumbers
- An array of field numbers to be refreshed by the Storefm
- The updated values are stored in this object. This object is only valid
for the duration of this call.protected boolean areFieldsLoaded(int[] fieldNumbers)
fieldNumbers
- The field numbers to checkpublic void unloadNonFetchPlanFields()
unloadNonFetchPlanFields
in interface ObjectProvider
protected void markPKFieldsAsLoaded()
protected void updateLevel2CacheForFields(int[] fieldNumbers)
fieldNumbers
- Numbers of fields to update in L2 cached objectprotected int[] loadFieldsFromLevel2Cache(int[] fieldNumbers)
fieldNumbers
- Numbers of fields to load from the L2 cachepublic void loadFieldsInFetchPlan(FetchPlanState state)
loadFieldsInFetchPlan
in interface ObjectProvider
state
- The FetchPlan statepublic void loadFieldFromDatastore(int fieldNumber)
loadFieldFromDatastore
in interface ObjectProvider
fieldNumber
- The field number.protected void loadFieldsFromDatastore(int[] fieldNumbers)
fieldNumbers
- The field numbers.protected int[] getFieldNumbersOfLoadedOrDirtyFields(boolean[] loadedFields, boolean[] dirtyFields)
loadedFields
- Fields that were detached with the objectdirtyFields
- Fields that have been modified while detachedpublic boolean[] getDirtyFields()
dirtyFields
bitmap.getDirtyFields
in interface ObjectProvider
dirtyFields
bitmap.public int[] getDirtyFieldNumbers()
getDirtyFieldNumbers
in interface ObjectProvider
public boolean[] getLoadedFields()
getLoadedFields
in interface ObjectProvider
public int[] getLoadedFieldNumbers()
getLoadedFieldNumbers
in interface ObjectProvider
public boolean getAllFieldsLoaded()
getAllFieldsLoaded
in interface ObjectProvider
public String[] getDirtyFieldNames()
getDirtyFieldNames
in interface ObjectProvider
public String[] getLoadedFieldNames()
getLoadedFieldNames
in interface ObjectProvider
public boolean isFieldLoaded(int fieldNumber)
isFieldLoaded
in interface ObjectProvider
fieldNumber
- The (absolute) field numberprotected void clearFieldsByNumbers(int[] fieldNumbers)
protected void clearDirtyFlags()
protected void clearDirtyFlags(int[] fieldNumbers)
fieldNumbers
- the fields to clearpublic void unloadField(String fieldName)
unloadField
in interface ObjectProvider
fieldName
- Name of the field/propertyNucleusUserException
- if the object managed by this StateManager is embeddedpublic boolean isEmbedded()
isEmbedded
in interface ObjectProvider
public void setPcObjectType(short objType)
setPcObjectType
in interface ObjectProvider
objType
- The type of object being managedpublic void lock(short lockMode)
ObjectProvider
lock
in interface ObjectProvider
lockMode
- Lock mode to applypublic void unlock()
ObjectProvider
unlock
in interface ObjectProvider
public short getLockMode()
ObjectProvider
getLockMode
in interface ObjectProvider
public void setAssociatedValue(Object key, Object value)
setAssociatedValue
in interface ObjectProvider
key
- Key for the valuevalue
- The associated valuepublic Object getAssociatedValue(Object key)
getAssociatedValue
in interface ObjectProvider
key
- Key for the valuepublic void removeAssociatedValue(Object key)
ObjectProvider
removeAssociatedValue
in interface ObjectProvider
key
- The keypublic boolean containsAssociatedValue(Object key)
protected static ObjectValueGenerator getObjectValueGenerator(ExecutionContext ec, String genName)
ec
- ExecutionContextgenName
- The generator nameNucleusException
- if no generator of that name is foundCopyright © 2019. All rights reserved.