public class ExecutionContextThreadedImpl extends ExecutionContextImpl
This class *tries to be* thread-safe, but there is no guarantee. You are better advised to design your application to use ExecutionContextImpl for a single thread.
ExecutionContext.EmbeddedOwnerRelation, ExecutionContext.LifecycleListener
Modifier and Type | Field and Description |
---|---|
protected Lock |
lock
Lock object for use during commit/rollback/evict, to prevent any further field accesses.
|
cache, opAssociatedValuesMapByOP
OPTION_JTA_AUTOJOIN, OPTION_PASSWORD, OPTION_USERNAME
Constructor and Description |
---|
ExecutionContextThreadedImpl(PersistenceNucleusContext ctx,
Object owner,
Map<String,Object> options) |
Modifier and Type | Method and Description |
---|---|
void |
addObjectProviderToCache(ObjectProvider op)
Method to add the object managed by the specified ObjectProvider to the (L1) cache.
|
void |
attachObject(ObjectProvider ownerOP,
Object pc,
boolean sco)
Method to attach a persistent detached object.
|
Object |
attachObjectCopy(ObjectProvider ownerOP,
Object pc,
boolean sco)
Method to attach a persistent detached object returning an attached copy of the object.
|
void |
clearDirty()
Method to clear all objects marked as dirty (whether directly or indirectly).
|
void |
clearDirty(ObjectProvider op)
Method to clear an object from the list of dirty objects.
|
void |
close()
Method to close the context.
|
void |
deleteObject(Object obj)
Method to delete an object from the datastore.
|
void |
deleteObjects(Object... objs)
Method to delete an array of objects from the datastore.
|
void |
detachObject(FetchPlanState state,
Object obj)
Method to detach a persistent object without making a copy.
|
Object |
detachObjectCopy(Object pc,
FetchPlanState state) |
void |
detachObjects(FetchPlanState state,
Object... objs)
Method to detach the passed object(s).
|
void |
enlistInTransaction(ObjectProvider sm)
Method to enlist the specified ObjectProvider in the current transaction.
|
void |
evictAllObjects()
Method to evict all current objects from L1 cache.
|
void |
evictFromTransaction(ObjectProvider sm)
Method to evict the specified ObjectProvider from the current transaction.
|
void |
evictObject(Object obj)
Internal method to evict an object from L1 cache.
|
void |
evictObjects(Class cls,
boolean subclasses)
Method to evict all objects of the specified type (and optionaly its subclasses) that are present in the L1 cache.
|
ObjectProvider |
findObjectProvider(Object pc)
Method to return the ObjectProvider for an object (if managed).
|
void |
flush()
Method callable from external APIs for user-management of flushing.
|
void |
flushInternal(boolean flushToDatastore)
This method flushes all dirty, new, and deleted instances to the datastore.
|
Extent |
getExtent(Class pcClass,
boolean subclasses)
Extents are collections of datastore objects managed by the datastore,
not by explicit user operations on collections.
|
Lock |
getLock()
Accessor for the context lock object.
|
boolean |
getMultithreaded()
Accessor for whether the usage is multi-threaded.
|
List<ObjectProvider> |
getObjectsToBeFlushed()
Convenience method to inspect the list of objects with outstanding changes to flush.
|
void |
makeObjectTransactional(Object obj)
Method to make an object transactional.
|
void |
makeObjectTransient(Object obj,
FetchPlanState state)
Method to migrate an object to transient state.
|
void |
markDirty(ObjectProvider op,
boolean directUpdate)
Method to mark an object (ObjectProvider) as dirty.
|
Object |
persistObject(Object obj,
boolean merging)
Method to make an object persistent.
|
Object[] |
persistObjects(Object... objs)
Method to persist an array of objects to the datastore.
|
void |
postBegin()
Method to perform any post-begin checks.
|
void |
postCommit()
Commit any changes made to objects managed by the object manager to the database.
|
void |
postRollback()
Callback invoked after the actual datastore rollback.
|
void |
preCommit()
Method to perform any pre-commit checks.
|
void |
preRollback()
Rollback any changes made to objects managed by the object manager to the database.
|
void |
processNontransactionalUpdate()
Method called when a non-tx update has been performed (via setter call on the persistable object, or via
use of mutator methods of a field).
|
void |
refreshAllObjects()
Method to do a refresh of all objects.
|
void |
refreshObject(Object obj)
Method to do a refresh of an object, updating it from its datastore representation.
|
void |
removeObjectProviderFromCache(ObjectProvider op)
Method to remove the object managed by the specified ObjectProvider from the cache.
|
void |
replaceObjectId(Object pc,
Object oldID,
Object newID)
Replace the previous object id for a persistable object with a new one.
|
void |
retrieveObject(Object obj,
boolean fgOnly)
Method to retrieve an object.
|
acquireThreadContextInfo, addInternalFetchGroup, addOperationToQueue, assertActiveTransaction, assertClassPersistable, assertDetachable, assertHasImplementationCreator, assertIsOpen, assertNotDetached, closeCallbackHandler, containsObjectProviderAssociatedValue, deleteObjectInternal, deregisterEmbeddedRelation, deregisterExecutionContextListener, detachAll, detachObjectCopy, exists, findObject, findObject, findObject, findObject, findObjectByUnique, findObjectProvider, findObjectProviderForEmbedded, findObjectProviderOfOwnerForAttachingObject, findObjects, findObjectsById, flushOperationsForBackingStore, getAttachDetachReferencedObject, getAttachedObjectForId, getBooleanProperty, getCallbackHandler, getClassLoaderResolver, getEmbeddedInformationForOwner, getFetchGroupManager, getFetchGroupsWithName, getFetchPlan, getFlushMode, getInternalFetchGroup, getIntProperty, getL2CacheableObject, getLevel1Cache, getLevel2CacheRetrieveMode, getLevel2CacheStoreMode, getLockManager, getManagedObjects, getManagedObjects, getManagedObjects, getManagedObjects, getManageRelations, getNucleusContext, getObjectFromCache, getObjectFromLevel1Cache, getObjectFromLevel2Cache, getObjectFromLevel2CacheForUnique, getObjectProviderAssociatedValue, getObjectsFromCache, getObjectsFromLevel2Cache, getOperationQueue, getOwner, getOwnerInformationForEmbedded, getOwnersForEmbeddedObjectProvider, getProperties, getProperty, getRelationshipManager, getSerializeReadForClass, getStatistics, getStringProperty, getSupportedProperties, getThreadContextInfo, getTransaction, hasIdentityInCache, hasPersistenceInformationForClass, initialise, initialiseLevel1Cache, isClosed, isDelayDatastoreOperationsEnabled, isEnlistedInTransaction, isFlushing, isInserting, isManagingRelations, isObjectModifiedInTransaction, isRunningDetachAllOnCommit, makeObjectNontransactional, markFieldsForUpdateInLevel2Cache, newInstance, newObjectId, newObjectId, operationQueueIsActive, persistObjectInternal, persistObjectInternal, processNontransactionalAtomicChanges, putObjectIntoLevel1Cache, putObjectIntoLevel2Cache, putObjectIntoLevel2CacheInternal, putObjectsIntoLevel2Cache, registerEmbeddedRelation, registerExecutionContextListener, releaseThreadContextInfo, removeEmbeddedOwnerRelation, removeInternalFetchGroup, removeObjectFromLevel1Cache, removeObjectFromLevel2Cache, removeObjectProviderAssociatedValue, setAttachDetachReferencedObject, setLevel2Cache, setObjectProviderAssociatedValue, setProperties, setProperty, transactionCommitted, transactionEnded, transactionFlushed, transactionPreCommit, transactionPreFlush, transactionPreRollBack, transactionReleaseSavepoint, transactionRollbackToSavepoint, transactionRolledBack, transactionSetSavepoint, transactionStarted
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getApiAdapter, getMetaDataManager, getStoreManager, getTypeManager, persistObjectInternal
protected Lock lock
public ExecutionContextThreadedImpl(PersistenceNucleusContext ctx, Object owner, Map<String,Object> options)
ctx
- NucleusContextowner
- Owner object (PM, EM)options
- Any options affecting startuppublic Lock getLock()
public boolean getMultithreaded()
getMultithreaded
in interface ExecutionContext
getMultithreaded
in class ExecutionContextImpl
public void processNontransactionalUpdate()
ExecutionContextImpl
processNontransactionalUpdate
in interface ExecutionContext
processNontransactionalUpdate
in class ExecutionContextImpl
public void enlistInTransaction(ObjectProvider sm)
ExecutionContextImpl
enlistInTransaction
in interface ExecutionContext
enlistInTransaction
in class ExecutionContextImpl
sm
- The ObjectProviderpublic void evictFromTransaction(ObjectProvider sm)
ExecutionContextImpl
evictFromTransaction
in interface ExecutionContext
evictFromTransaction
in class ExecutionContextImpl
sm
- The ObjectProviderpublic void addObjectProviderToCache(ObjectProvider op)
ExecutionContextImpl
addObjectProviderToCache
in interface ExecutionContext
addObjectProviderToCache
in class ExecutionContextImpl
op
- The ObjectProviderpublic void removeObjectProviderFromCache(ObjectProvider op)
ExecutionContextImpl
removeObjectProviderFromCache
in interface ExecutionContext
removeObjectProviderFromCache
in class ExecutionContextImpl
op
- The ObjectProviderpublic ObjectProvider findObjectProvider(Object pc)
ExecutionContextImpl
findObjectProvider
in interface ExecutionContext
findObjectProvider
in class ExecutionContextImpl
pc
- The object we are checkingpublic void close()
ExecutionContextImpl
close
in interface ExecutionContext
close
in class ExecutionContextImpl
public void evictObject(Object obj)
ExecutionContextImpl
evictObject
in interface ExecutionContext
evictObject
in class ExecutionContextImpl
obj
- The objectpublic void refreshObject(Object obj)
ExecutionContextImpl
refreshObject
in interface ExecutionContext
refreshObject
in class ExecutionContextImpl
obj
- The Objectpublic void retrieveObject(Object obj, boolean fgOnly)
ExecutionContextImpl
retrieveObject
in interface ExecutionContext
retrieveObject
in class ExecutionContextImpl
obj
- The objectfgOnly
- Whether to retrieve the current fetch group fields onlypublic Object persistObject(Object obj, boolean merging)
ExecutionContextImpl
persistObject
in interface ExecutionContext
persistObject
in class ExecutionContextImpl
obj
- The objectmerging
- Whether this object (and dependents) is being mergedpublic Object[] persistObjects(Object... objs)
ExecutionContextImpl
persistObjects
in interface ExecutionContext
persistObjects
in class ExecutionContextImpl
objs
- The objects to persistpublic void deleteObject(Object obj)
ExecutionContextImpl
deleteObject
in interface ExecutionContext
deleteObject
in class ExecutionContextImpl
obj
- The objectpublic void deleteObjects(Object... objs)
ExecutionContextImpl
deleteObjects
in interface ExecutionContext
deleteObjects
in class ExecutionContextImpl
objs
- The objectspublic void makeObjectTransient(Object obj, FetchPlanState state)
ExecutionContextImpl
makeObjectTransient
in interface ExecutionContext
makeObjectTransient
in class ExecutionContextImpl
obj
- The objectstate
- Object containing the state of the fetch plan process (if any)public void makeObjectTransactional(Object obj)
ExecutionContextImpl
makeObjectTransactional
in interface ExecutionContext
makeObjectTransactional
in class ExecutionContextImpl
obj
- The objectpublic void attachObject(ObjectProvider ownerOP, Object pc, boolean sco)
ExecutionContextImpl
attachObject
in interface ExecutionContext
attachObject
in class ExecutionContextImpl
ownerOP
- ObjectProvider of the owner object that has this in a field that causes this attachpc
- The persistable objectsco
- Whether the PC object is stored without an identity (embedded/serialised)public Object attachObjectCopy(ObjectProvider ownerOP, Object pc, boolean sco)
ExecutionContextImpl
attachObjectCopy
in interface ExecutionContext
attachObjectCopy
in class ExecutionContextImpl
ownerOP
- ObjectProvider of the owner object that has this in a field that causes this attachpc
- The objectsco
- Whether it has no identity (second-class object)public void detachObject(FetchPlanState state, Object obj)
ExecutionContextImpl
detachObject
in interface ExecutionContext
detachObject
in class ExecutionContextImpl
state
- State for the detachment processobj
- The objectpublic void detachObjects(FetchPlanState state, Object... objs)
ExecutionContext
detachObjects
in interface ExecutionContext
detachObjects
in class ExecutionContextImpl
state
- State for the detachment process.objs
- The object(s) to detachpublic Object detachObjectCopy(Object pc, FetchPlanState state)
public void clearDirty(ObjectProvider op)
ExecutionContextImpl
clearDirty
in interface ExecutionContext
clearDirty
in class ExecutionContextImpl
op
- The ObjectProviderpublic void clearDirty()
ExecutionContextImpl
clearDirty
in interface ExecutionContext
clearDirty
in class ExecutionContextImpl
public void evictAllObjects()
evictAllObjects
in interface ExecutionContext
evictAllObjects
in class ExecutionContextImpl
public void markDirty(ObjectProvider op, boolean directUpdate)
ExecutionContextImpl
markDirty
in interface ExecutionContext
markDirty
in class ExecutionContextImpl
op
- ObjectProviderdirectUpdate
- Whether the object has had a direct update made on it (if known)public void flush()
ExecutionContextImpl
flush
in interface ExecutionContext
flush
in class ExecutionContextImpl
public void flushInternal(boolean flushToDatastore)
ExecutionContextImpl
flushInternal
in interface ExecutionContext
flushInternal
in class ExecutionContextImpl
flushToDatastore
- Whether to ensure any changes reach the datastore
Otherwise they will be flushed to the datastore manager and leave it to
decide the opportune moment to actually flush them to the datastorepublic void replaceObjectId(Object pc, Object oldID, Object newID)
ExecutionContextImpl
replaceObjectId
in interface ExecutionContext
replaceObjectId
in class ExecutionContextImpl
pc
- The Persistable objectoldID
- the old id it was known bynewID
- the new idpublic Extent getExtent(Class pcClass, boolean subclasses)
ExecutionContextImpl
getExtent
in interface ExecutionContext
getExtent
in class ExecutionContextImpl
pcClass
- The class to querysubclasses
- Whether to include subclasses in the query.public void evictObjects(Class cls, boolean subclasses)
ExecutionContextImpl
evictObjects
in interface ExecutionContext
evictObjects
in class ExecutionContextImpl
cls
- Type of persistable objectsubclasses
- Whether to include subclassespublic void refreshAllObjects()
ExecutionContextImpl
refreshAllObjects
in interface ExecutionContext
refreshAllObjects
in class ExecutionContextImpl
public List<ObjectProvider> getObjectsToBeFlushed()
ExecutionContextImpl
getObjectsToBeFlushed
in interface ExecutionContext
getObjectsToBeFlushed
in class ExecutionContextImpl
public void postBegin()
ExecutionContextImpl
postBegin
in class ExecutionContextImpl
public void preCommit()
ExecutionContextImpl
preCommit
in class ExecutionContextImpl
public void postCommit()
ExecutionContextImpl
postCommit
in class ExecutionContextImpl
public void preRollback()
ExecutionContextImpl
preRollback
in class ExecutionContextImpl
public void postRollback()
ExecutionContextImpl
postRollback
in class ExecutionContextImpl
Copyright © 2019. All rights reserved.