|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.datanucleus.ObjectManagerImpl
public class ObjectManagerImpl
Managed for persistence, representing the execution context. Provides the basics of object persistence internally, upon which are built javax.jdo.PersistenceManager and javax.persistence.EntityManager. An object manager provides management for the persistence of objects into a datastore and the retrieval of these objects using various methods.
An ObjectManager has its own Level 1 cache. This stores objects against their identity. The Level 1 cache is typically a weak referenced map and so cached objects can be garbage collected. Objects are placed in the Level 1 cache during the transaction. The ObjectManagerFactory also has a Level 2 cache. This is used to allow cross-communication between ObjectManagers. Objects are placed in the Level 2 cache during commit() of a transaction. If an object is deleted during a transaction then it will be removed from the Level 2 cache at commit(). If an object is no longer enlisted in the transaction at commit then it will be removed from the Level 2 cache (so we remove the chance of handing out old data).
An ObjectManager has a single transaction (the "current" transaction). The transaction can be "active" (if begin() has been called on it) or "inactive".
When an object involved in the current transaction it is enlisted (calling enlistInTransaction()). Its' identity is saved (in "txEnlistedIds") for use later in any "persistenceByReachability" process run at commit. Any object that is passed via makePersistent() will be stored (as an identity) in "txKnownPersistedIds" and objects persisted due to reachability from these objects will also have their identity stored (in "txFlushedNewIds"). All of this information is used in the "persistence-by-reachability-at-commit" process which detects if some objects originally persisted are no longer reachable and hence should not be persistent after all.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.datanucleus.store.ExecutionContext |
|---|
ExecutionContext.LifecycleListener |
| Field Summary | |
|---|---|
protected Level1Cache |
cache
Level 1 Cache, essentially a Map of ObjectProvider keyed by the id. |
protected static Localiser |
LOCALISER
Localisation utility for output messages |
protected Lock |
lock
Lock object for use during commit/rollback/evict, to prevent any further field accesses. |
| Constructor Summary | |
|---|---|
ObjectManagerImpl(NucleusContext ctx,
Object owner,
String userName,
String password)
Constructor. |
|
| Method Summary | |
|---|---|
protected org.datanucleus.ObjectManagerImpl.ThreadContextInfo |
acquireThreadContextInfo()
Accessor for the thread context information, for the current thread. |
void |
addInternalFetchGroup(FetchGroup grp)
Method to add a dynamic FetchGroup. |
void |
addListener(Object listener,
Class[] classes)
Method to register a listener for instances of the specified classes. |
void |
addObjectProvider(ObjectProvider op)
Method to add the object managed by the specified ObjectProvider to the (L1) cache. |
protected void |
assertActiveTransaction()
Method to assert if the current transaction is active. |
void |
assertClassPersistable(Class cls)
Method to assert if the specified class is Persistence Capable. |
protected void |
assertDetachable(Object object)
Method to assert if the specified object is Detachable. |
protected void |
assertHasImplementationCreator()
Validates that an ImplementationCreator instance is accessible. |
protected void |
assertIsOpen()
Method to assert if this Object Manager is open. |
protected void |
assertNotDetached(Object object)
Method to assert if the specified object is detached. |
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 Object Manager. |
void |
deleteObject(Object obj)
Method to delete an object from the datastore. |
void |
deleteObjectInternal(Object obj)
Method to delete an object from persistence which should be called from internal calls only. |
void |
deleteObjects(Object[] objs)
Method to delete an array of objects from the datastore. |
void |
detachAll()
Method to detach all objects in the ObjectManager. |
void |
detachObject(Object obj,
FetchPlanState state)
Method to detach a persistent object without making a copy. |
Object |
detachObjectCopy(Object pc,
FetchPlanState state)
Detach a copy of the passed persistent object using the provided detach state. |
void |
disconnectLifecycleListener()
Disconnect the registered LifecycleListener |
protected void |
disconnectObjectProvidersFromCache()
Disconnect ObjectProviders that are cached from their objects, and removes them from the cache. |
void |
enlistInTransaction(ObjectProvider op)
Method to enlist the specified ObjectProvider in the current transaction. |
void |
evictAllObjects()
Method to evict all current objects from L1 cache. |
void |
evictFromTransaction(ObjectProvider op)
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. |
boolean |
exists(Object obj)
Method to return if the specified object exists in the datastore. |
Object |
findObject(Object id,
boolean validate,
boolean checkInheritance,
String objectClassName)
Accessor for an object given the object id. |
Object |
findObject(Object id,
FieldValues fv,
Class cls,
boolean ignoreCache,
boolean checkInheritance)
Accessor for an object given the object id and a set of field values to apply to it. |
ObjectProvider |
findObjectProvider(Object pc)
Method to find the ObjectProvider for an object. |
ObjectProvider |
findObjectProvider(Object pc,
boolean persist)
Method to find the ObjectProvider for the passed persistable object when it is managed by this manager, and if not yet persistent to persist it. |
ObjectProvider |
findObjectProviderForEmbedded(Object value,
ObjectProvider owner,
AbstractMemberMetaData mmd)
Method to find the ObjectProvider for the passed embedded persistable object. |
Object[] |
findObjects(Object[] identities,
boolean validate)
Accessor for objects with the specified identities. |
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. |
protected List<NucleusOptimisticException> |
flushInternalNonReferential()
Flush method for cases where the datastore doesn't use referential integrity so we can send batches of deletes, then batches of inserts, then any updates to optimise the persistence. |
protected List<NucleusOptimisticException> |
flushInternalWithOrdering()
Flush process that takes the objects in the order that they became dirty. |
ApiAdapter |
getApiAdapter()
Accessor for the API adapter. |
Object |
getAttachedObjectForId(Object id)
Convenience method to return the attached object for the specified id if one exists. |
Boolean |
getBooleanProperty(String name)
Accessor for a boolean property value. |
CallbackHandler |
getCallbackHandler()
Retrieve the callback handler for this ObjectManager. |
ClassLoaderResolver |
getClassLoaderResolver()
Accessor for the ClassLoader resolver to use in class loading issues. |
boolean |
getCopyOnAttach()
Accessor for whether to copy on attaching. |
Integer |
getDatastoreReadTimeoutMillis()
Accessor for the datastore read timeout in milliseconds. |
Integer |
getDatastoreWriteTimeoutMillis()
Accessor for the datastore write timeout in milliseconds. |
protected boolean |
getDetachAllOnCommit()
Accessor for whether to detach all objects on commit of the transaction. |
protected boolean |
getDetachAllOnRollback()
Accessor for whether to detach all objects on rollback of the transaction. |
protected boolean |
getDetachOnClose()
Accessor for whether to detach objects on close of the ObjectManager. |
Extent |
getExtent(Class pcClass,
boolean subclasses)
Extents are collections of datastore objects managed by the datastore, not by explicit user operations on collections. |
protected FetchGroupManager |
getFetchGroupManager()
Convenience accessor for the FetchGroupManager. |
Set |
getFetchGroupsWithName(String name)
Accessor for the fetch groups for the specified name. |
FetchPlan |
getFetchPlan()
Acessor for the current FetchPlan. |
boolean |
getIgnoreCache()
Accessor for whether to ignore the cache. |
FetchGroup |
getInternalFetchGroup(Class cls,
String name)
Accessor for an internal fetch group for the specified class. |
Integer |
getIntProperty(String name)
Accessor for an int property value. |
protected CachedPC |
getL2CacheableObject(ObjectProvider op)
Convenience method to convert the object managed by the ObjectProvider into a form suitable for caching in an L2 cache. |
Lock |
getLock()
Accessor for the ObjectManager lock object. |
LockManager |
getLockManager()
Accessor for the lock manager for this execution context. |
Set |
getManagedObjects()
Accessor for the currently managed objects for the current transaction. |
Set |
getManagedObjects(Class[] classes)
Accessor for the currently managed objects for the current transaction. |
Set |
getManagedObjects(String[] states)
Accessor for the currently managed objects for the current transaction. |
Set |
getManagedObjects(String[] states,
Class[] classes)
Accessor for the currently managed objects for the current transaction. |
boolean |
getManageRelations()
Accessor for whether to manage relationships at flush/commit. |
boolean |
getManageRelationsChecks()
Accessor for whether to manage relationships checks at flush/commit. |
MetaDataManager |
getMetaDataManager()
Accessor for the MetaDataManager for this ObjectManager (and its factory). |
boolean |
getMultithreaded()
Accessor for whether the object manager is multithreaded. |
NucleusContext |
getNucleusContext()
Gets the context in which this ObjectManager is running |
Object |
getObjectFromCache(Object id)
Convenience method to access an object in the cache. |
Object |
getObjectFromLevel1Cache(Object id)
Convenience method to access an object in the Level 1 cache. |
Object |
getObjectFromLevel2Cache(Object id)
Convenience method to access an object in the Level 2 cache. |
protected Map |
getObjectsFromLevel2Cache(Collection ids)
Convenience method to access a collection of objects from the Level 2 cache. |
List<ObjectProvider> |
getObjectsToBeFlushed()
Convenience method to inspect the list of objects with outstanding changes to flush. |
Object |
getOwner()
Method to return the owner PM object. |
Map<String,Object> |
getProperties()
Accessor for the defined properties. |
Object |
getProperty(String name)
Accessor for a property. |
protected boolean |
getReachabilityAtCommit()
Accessor for whether to run the reachability algorithm at commit time. |
RelationshipManager |
getRelationshipManager(ObjectProvider op)
Accessor for the RelationshipManager for the provided ObjectProvider. |
boolean |
getSerializeReadForClass(String className)
Convenience method to return the setting for serialize read for the current transaction for the specified class name. |
ManagerStatistics |
getStatistics()
Accessor for any statistics-gathering object. |
StoreManager |
getStoreManager()
Accessor for the Store Manager. |
Set<String> |
getSupportedProperties()
Accessor for the supported property names. |
protected org.datanucleus.ObjectManagerImpl.ThreadContextInfo |
getThreadContextInfo()
Get the current ThreadContextInfo assigned to the current thread without changing the reference counter. |
Transaction |
getTransaction()
Accessor for the current transaction. |
TypeManager |
getTypeManager()
TODO should we keep this here? this is api/language dependent |
boolean |
hasIdentityInCache(Object id)
Whether the specified identity is cached currently. |
boolean |
hasPersistenceInformationForClass(Class cls)
Utility method to check if the specified class has reachable metadata or annotations. |
void |
hereIsObjectProvider(ObjectProvider op,
Object pc)
Method to add the ObjectProvider for an object to this ObjectManager's list. |
protected void |
initialiseLevel1Cache()
Method to initialise the L1 cache. |
boolean |
isClosed()
Accessor for whether this ObjectManager is closed. |
boolean |
isDelayDatastoreOperationsEnabled()
Whether the datastore operations are delayed until commit/flush. |
boolean |
isEnlistedInTransaction(Object id)
Method to return if an object is enlisted in the current transaction. |
boolean |
isFlushing()
Returns whether the ObjectManager is in the process of flushing. |
boolean |
isInserting(Object pc)
Tests whether this persistable object is in the process of being inserted. |
boolean |
isManagingRelations()
Returns whether this ObjectManager is currently performing the manage relationships task. |
boolean |
isObjectModifiedInTransaction(Object id)
Accessor for whether the object with this identity is modified in the current transaction. |
boolean |
isRunningDetachAllOnCommit()
Accessor for whether this ObjectManager is currently running detachAllOnCommit. |
void |
makeObjectNontransactional(Object obj)
Method to make an object nontransactional. |
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 |
newInstance(Class cls)
Method to generate an instance of an interface, abstract class, or concrete PC class. |
Object |
newObjectId(Class pcClass,
Object key)
This method returns an object id instance corresponding to the pcClass and key arguments. |
Object |
newObjectId(String className,
Object pc)
This method returns an object id instance corresponding to the class name, and the passed object (when using app identity). |
protected ObjectProvider |
newObjectProviderForCachedPC(Object id,
CachedPC cachedPC)
Constructor to create a ObjectProvider for an object taken from the L2 cache with the specified id. |
ObjectProvider |
newObjectProviderForDetached(Object pc,
Object id,
Object version)
Constructor for creating ObjectProvider instances to manage persistable objects in detached state. |
ObjectProvider |
newObjectProviderForEmbedded(AbstractClassMetaData cmd,
ObjectProvider ownerOP,
int ownerFieldNumber)
Constructs an ObjectProvider for an object of the specified type, creating the PC object to hold the values where this object will be EMBEDDED/SERIALISED into another persistable object. |
ObjectProvider |
newObjectProviderForEmbedded(Object pc,
boolean copyPc,
ObjectProvider ownerOP,
int ownerFieldNumber)
Constructs an ObjectProvider to manage a persistable instance that will be EMBEDDED/SERIALISED into another persistable object. |
ObjectProvider |
newObjectProviderForHollow(Class pcClass,
Object id)
Constructs an ObjectProvider to manage a hollow instance having the given object ID. |
ObjectProvider |
newObjectProviderForHollowPopulated(Class pcClass,
Object id,
FieldValues fv)
Constructs an ObjectProvider to manage a recently populated hollow instance having the given object ID and the given field values. |
ObjectProvider |
newObjectProviderForHollowPopulatedAppId(Class pcClass,
FieldValues fv)
Deprecated. Use newObjectProviderForHollowPopulated instead |
ObjectProvider |
newObjectProviderForHollowPreConstructed(Object id,
Object pc)
Constructs an ObjectProvider to manage a hollow instance having the given object ID. |
ObjectProvider |
newObjectProviderForPersistentClean(Object id,
Object pc)
Constructs an ObjectProvider to manage the specified persistent instance having the given object ID. |
ObjectProvider |
newObjectProviderForPersistentNew(Object pc,
FieldValues preInsertChanges)
Constructs an ObjectProvider to manage a transient instance that is becoming newly persistent. |
ObjectProvider |
newObjectProviderForPNewToBeDeleted(Object pc)
Constructor for creating ObjectProvider instances to manage persistable objects that are not persistent yet are about to be deleted. |
ObjectProvider |
newObjectProviderForTransactionalTransient(Object pc)
Constructs an ObjectProvider to manage a Transactional-Transient instance. |
Query |
newQuery()
Construct an empty query instance. |
protected void |
performManagedRelationships()
Method to perform managed relationships tasks. |
Object |
persistObject(Object obj,
boolean merging)
Method to make an object persistent. |
Object |
persistObjectInternal(Object pc,
FieldValues preInsertChanges,
int objectType)
Method to persist the passed object (internally). |
Object |
persistObjectInternal(Object obj,
FieldValues preInsertChanges,
ObjectProvider ownerOP,
int ownerFieldNum,
int objectType)
Method to make an object persistent which should be called from internal calls only. |
Object |
persistObjectInternal(Object pc,
ObjectProvider ownerOP,
int ownerFieldNum,
int objectType)
Method to persist the passed object (internally). |
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. |
protected void |
processNontransactionalAtomicChanges()
Handler for all outstanding changes to be "committed" atomically. |
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 |
putObjectIntoLevel1Cache(ObjectProvider op)
Convenience method to add an object to the L1 cache. |
protected void |
putObjectIntoLevel2Cache(ObjectProvider op,
boolean updateIfPresent)
Method to add/update the managed object into the L2 cache as long as it isn't modified in the current transaction. |
protected void |
putObjectIntoLevel2CacheInternal(ObjectProvider op,
boolean updateIfPresent)
Convenience method to add/update an object in the L2 cache. |
protected void |
putObjectsIntoLevel2Cache(Set<ObjectProvider> ops)
Method to put the passed objects into the L2 cache. |
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. |
protected void |
releaseThreadContextInfo()
Method to remove the current thread context info for the current thread, after the reference counter reached 0. |
void |
removeAllInstanceLifecycleListeners()
This method removes all previously registered lifecycle listeners. |
protected void |
removeInternalFetchGroup(FetchGroup grp)
Method to remove a dynamic FetchGroup. |
void |
removeListener(Object listener)
Method to remove a currently registered listener. |
void |
removeObjectFromLevel1Cache(Object id)
Convenience method to evict an object from the L1 cache. |
void |
removeObjectFromLevel2Cache(Object id)
Convenience method to remove the object with the specified identity from the L2 cache. |
void |
removeObjectProvider(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. |
void |
setProperties(Map props)
Method to set properties on the execution context. |
void |
setProperty(String name,
Object value)
Method to set a property on the execution context |
void |
transactionCommitted()
Method invoked when the transaction is committed. |
void |
transactionEnded()
Method invoked when the transaction is ended (Using XA). |
void |
transactionFlushed()
Method invoked when the transaction is flushed (happens before commit, rollback). |
void |
transactionPreCommit()
Method invoked before the transaction commit. |
void |
transactionPreFlush()
Method invoked just before a flush. |
void |
transactionPreRollBack()
Method invoked before the transaction is rolledback. |
void |
transactionRolledBack()
Method invoked when the transaction is rolled back. |
void |
transactionStarted()
Method invoked when the transaction is started. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Localiser LOCALISER
protected Level1Cache cache
protected Lock lock
| Constructor Detail |
|---|
public ObjectManagerImpl(NucleusContext ctx,
Object owner,
String userName,
String password)
ctx - NucleusContextowner - The owning PM/EM depending on calling API.userName - Username for the datastorepassword - Password for the datastore
NucleusUserException - if an error occurs allocating the necessary requested components| Method Detail |
|---|
protected org.datanucleus.ObjectManagerImpl.ThreadContextInfo acquireThreadContextInfo()
You must call releaseThreadContextInfo() when you don't need it anymore,
since we use reference counting. Use a try...finally-block for this purpose.
getThreadContextInfo()protected org.datanucleus.ObjectManagerImpl.ThreadContextInfo getThreadContextInfo()
acquireThreadContextInfo()protected void releaseThreadContextInfo()
acquireThreadContextInfo().
acquireThreadContextInfo()public void transactionStarted()
TransactionEventListener
transactionStarted in interface TransactionEventListenerpublic void transactionPreFlush()
TransactionEventListener
transactionPreFlush in interface TransactionEventListenerpublic void transactionFlushed()
TransactionEventListener
transactionFlushed in interface TransactionEventListenerpublic void transactionPreCommit()
TransactionEventListener
transactionPreCommit in interface TransactionEventListenerpublic void transactionCommitted()
TransactionEventListener
transactionCommitted in interface TransactionEventListenerpublic void transactionPreRollBack()
TransactionEventListener
transactionPreRollBack in interface TransactionEventListenerpublic void transactionRolledBack()
TransactionEventListener
transactionRolledBack in interface TransactionEventListenerpublic void transactionEnded()
TransactionEventListener
transactionEnded in interface TransactionEventListenerpublic ManagerStatistics getStatistics()
ExecutionContext
getStatistics in interface ExecutionContextprotected void initialiseLevel1Cache()
NucleusUserException - if an error occurs setting up the L1 cachepublic boolean isClosed()
isClosed in interface ExecutionContextpublic ClassLoaderResolver getClassLoaderResolver()
ExecutionContext
getClassLoaderResolver in interface ExecutionContextpublic StoreManager getStoreManager()
ExecutionContext
getStoreManager in interface ExecutionContextpublic ApiAdapter getApiAdapter()
ExecutionContext
getApiAdapter in interface ExecutionContextpublic TypeManager getTypeManager()
ExecutionContext
getTypeManager in interface ExecutionContextpublic LockManager getLockManager()
ExecutionContext
getLockManager in interface ExecutionContextpublic FetchPlan getFetchPlan()
getFetchPlan in interface ExecutionContextpublic Object getOwner()
getOwner in interface ExecutionContextpublic NucleusContext getNucleusContext()
getNucleusContext in interface ExecutionContextpublic MetaDataManager getMetaDataManager()
getMetaDataManager in interface ExecutionContextpublic void setProperties(Map props)
ExecutionContext
setProperties in interface ExecutionContextprops - The properties
public void setProperty(String name,
Object value)
ExecutionContext
setProperty in interface ExecutionContextname - Name of the propertyvalue - Value to setpublic Map<String,Object> getProperties()
ExecutionContext
getProperties in interface ExecutionContextpublic Boolean getBooleanProperty(String name)
ExecutionContext
getBooleanProperty in interface ExecutionContextname - Name of the property
public Integer getIntProperty(String name)
ExecutionContext
getIntProperty in interface ExecutionContextname - Name of the property
public Object getProperty(String name)
ExecutionContext
getProperty in interface ExecutionContextname - Name of the property
public Set<String> getSupportedProperties()
ExecutionContext
getSupportedProperties in interface ExecutionContextpublic Integer getDatastoreReadTimeoutMillis()
getDatastoreReadTimeoutMillis in interface ExecutionContextpublic Integer getDatastoreWriteTimeoutMillis()
getDatastoreWriteTimeoutMillis in interface ExecutionContextpublic boolean getMultithreaded()
getMultithreaded in interface ExecutionContextprotected boolean getDetachOnClose()
protected boolean getDetachAllOnCommit()
protected boolean getDetachAllOnRollback()
protected boolean getReachabilityAtCommit()
public boolean getCopyOnAttach()
public boolean getIgnoreCache()
getIgnoreCache in interface ExecutionContextpublic boolean isDelayDatastoreOperationsEnabled()
isDelayDatastoreOperationsEnabled in interface ExecutionContextpublic boolean isInserting(Object pc)
isInserting in interface ExecutionContextpc - the object to verify the status
public Transaction getTransaction()
getTransaction in interface ExecutionContextpublic void enlistInTransaction(ObjectProvider op)
enlistInTransaction in interface ExecutionContextop - The ObjectProviderpublic void evictFromTransaction(ObjectProvider op)
evictFromTransaction in interface ExecutionContextop - The ObjectProviderpublic boolean isEnlistedInTransaction(Object id)
isEnlistedInTransaction in interface ExecutionContextid - Identity for the object
public Object getAttachedObjectForId(Object id)
getAttachedObjectForId in interface ExecutionContextid - The id
public void addObjectProvider(ObjectProvider op)
addObjectProvider in interface ExecutionContextop - The ObjectProviderpublic void removeObjectProvider(ObjectProvider op)
removeObjectProvider in interface ExecutionContextop - The ObjectProviderpublic ObjectProvider findObjectProvider(Object pc)
findObjectProvider in interface ExecutionContextpc - The object we are checking
public ObjectProvider findObjectProvider(Object pc,
boolean persist)
ExecutionContext
findObjectProvider in interface ExecutionContextpersist - persists the object if not yet persisted.pc - The persistable object
public ObjectProvider findObjectProviderForEmbedded(Object value,
ObjectProvider owner,
AbstractMemberMetaData mmd)
ExecutionContext
findObjectProviderForEmbedded in interface ExecutionContextvalue - The embedded objectowner - The owner ObjectProvider (if known).mmd - Metadata for the field of the owner
public ObjectProvider newObjectProviderForHollow(Class pcClass,
Object id)
newObjectProviderForHollow in interface ExecutionContextpcClass - the class of the new instance to be created.id - the JDO identity of the object.
public ObjectProvider newObjectProviderForHollowPreConstructed(Object id,
Object pc)
newObjectProviderForHollowPreConstructed in interface ExecutionContextid - the JDO identity of the object.pc - The object that is hollow that we are going to manage
public ObjectProvider newObjectProviderForHollowPopulated(Class pcClass,
Object id,
FieldValues fv)
newObjectProviderForHollowPopulated in interface ExecutionContextpcClass - the class of the new instance to be created.id - the JDO identity of the object.fv - the initial field values of the object.
public ObjectProvider newObjectProviderForPersistentClean(Object id,
Object pc)
newObjectProviderForPersistentClean in interface ExecutionContextid - the JDO identity of the object.pc - The object that is persistent that we are going to manage
public ObjectProvider newObjectProviderForHollowPopulatedAppId(Class pcClass,
FieldValues fv)
newObjectProviderForHollowPopulatedAppId in interface ExecutionContextpcClass - the class of the new instance to be created.fv - the initial field values of the object.
public ObjectProvider newObjectProviderForEmbedded(Object pc,
boolean copyPc,
ObjectProvider ownerOP,
int ownerFieldNumber)
newObjectProviderForEmbedded in interface ExecutionContextpc - The persistable to manage (see copyPc also)copyPc - Whether the SM should manage a copy of the passed PC or that oneownerOP - Owner ObjectProviderownerFieldNumber - Field number in owner object where this is stored
public ObjectProvider newObjectProviderForEmbedded(AbstractClassMetaData cmd,
ObjectProvider ownerOP,
int ownerFieldNumber)
newObjectProviderForEmbedded in interface ExecutionContextcmd - Meta-data for the class that this is an instance of.ownerOP - Owner ObjectProviderownerFieldNumber - Field number in owner object where this is stored
public ObjectProvider newObjectProviderForPersistentNew(Object pc,
FieldValues preInsertChanges)
newObjectProviderForPersistentNew in interface ExecutionContextpc - the instance being make persistent.preInsertChanges - Any changes to make before insertingpublic ObjectProvider newObjectProviderForTransactionalTransient(Object pc)
newObjectProviderForTransactionalTransient in interface ExecutionContextec - ExecutionContextpc - the instance being make persistent.
public ObjectProvider newObjectProviderForDetached(Object pc,
Object id,
Object version)
newObjectProviderForDetached in interface ExecutionContextpc - the detached objectid - the JDO identity of the object.version - the detached versionpublic ObjectProvider newObjectProviderForPNewToBeDeleted(Object pc)
newObjectProviderForPNewToBeDeleted in interface ExecutionContextpc - the object being deleted from persistence
protected ObjectProvider newObjectProviderForCachedPC(Object id,
CachedPC cachedPC)
id - Id to assign to the persistable objectcachedPC - CachedPC object from the L2 cache
public void hereIsObjectProvider(ObjectProvider op,
Object pc)
hereIsObjectProvider in interface ExecutionContextop - The ObjectProviderpc - The object managed by the ObjectProviderpublic void close()
close in interface ExecutionContextprotected void disconnectObjectProvidersFromCache()
public void processNontransactionalUpdate()
processNontransactionalUpdate in interface ExecutionContextprotected void processNontransactionalAtomicChanges()
public void evictObject(Object obj)
evictObject in interface ExecutionContextobj - The object
NucleusException - if an error occurs evicting the object
public void evictObjects(Class cls,
boolean subclasses)
evictObjects in interface ExecutionContextcls - Type of persistable objectsubclasses - Whether to include subclassespublic void evictAllObjects()
evictAllObjects in interface ExecutionContextpublic void refreshObject(Object obj)
refreshObject in interface ExecutionContextobj - The Objectpublic void refreshAllObjects()
refreshAllObjects in interface ExecutionContextNucleusUserException - thrown if instances could not be refreshed.
public void retrieveObject(Object obj,
boolean fgOnly)
retrieveObject in interface ExecutionContextobj - The objectfgOnly - Whether to retrieve the current fetch group fields only
public Object persistObject(Object obj,
boolean merging)
persistObject in interface ExecutionContextobj - The objectmerging - Whether this object (and dependents) is being merged
NucleusUserException - if the object is managed by a different managerpublic Object[] persistObjects(Object[] objs)
persistObjects in interface ExecutionContextobjs - The objects to persist
NucleusUserException - Thrown if an error occurs during the persist process.
Any exception could have several nested exceptions for each failed object persist
public Object persistObjectInternal(Object obj,
FieldValues preInsertChanges,
ObjectProvider ownerOP,
int ownerFieldNum,
int objectType)
persistObjectInternal in interface ExecutionContextobj - The objectpreInsertChanges - Any changes to make before insertingownerOP - ObjectProvider of the owner when embeddedownerFieldNum - Field number in the owner where this is embedded (or -1 if not embedded)objectType - Type of object (see org.datanucleus.ObjectProvider, e.g ObjectProvider.PC)
NucleusUserException - if the object is managed by a different manager
public Object persistObjectInternal(Object pc,
ObjectProvider ownerOP,
int ownerFieldNum,
int objectType)
persistObjectInternal in interface ExecutionContextpc - The objectownerOP - ObjectProvider of the owner when embeddedownerFieldNum - Field number in the owner where this is embedded (or -1 if not embedded)objectType - Type of object (see org.datanucleus.ObjectProvider, e.g ObjectProvider.PC)
public Object persistObjectInternal(Object pc,
FieldValues preInsertChanges,
int objectType)
ExecutionContext
persistObjectInternal in interface ExecutionContextpc - The objectpreInsertChanges - Changes to be made before insertingobjectType - Type of object (see org.datanucleus.StateManager, e.g StateManager.PC)
public void deleteObjects(Object[] objs)
deleteObjects in interface ExecutionContextobjs - The objects
NucleusUserException - Thrown if an error occurs during the deletion process.
Any exception could have several nested exceptions for each failed object deletionpublic void deleteObject(Object obj)
deleteObject in interface ExecutionContextobj - The objectpublic void deleteObjectInternal(Object obj)
deleteObjectInternal in interface ExecutionContextobj - Object to delete
public void makeObjectTransient(Object obj,
FetchPlanState state)
makeObjectTransient in interface ExecutionContextobj - The objectstate - Object containing the state of the fetch plan process (if any)
NucleusException - When an error occurs in making the object transientpublic void makeObjectTransactional(Object obj)
makeObjectTransactional in interface ExecutionContextobj - The object
NucleusException - Thrown when an error occurspublic void makeObjectNontransactional(Object obj)
makeObjectNontransactional in interface ExecutionContextobj - The object
public void attachObject(ObjectProvider ownerOP,
Object pc,
boolean sco)
attachObject in interface ExecutionContextownerOP - 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)
attachObjectCopy in interface ExecutionContextownerOP - 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(Object obj,
FetchPlanState state)
detachObject in interface ExecutionContextobj - The objectstate - State for the detachment process
public Object detachObjectCopy(Object pc,
FetchPlanState state)
detachObjectCopy in interface ExecutionContextpc - The objectstate - State for the detachment process
public void detachAll()
detachAll in interface ExecutionContextpublic Object newInstance(Class cls)
newInstance in interface ExecutionContextcls - The class of the interface or abstract class, or concrete class defined in MetaData
public boolean exists(Object obj)
exists in interface ExecutionContextobj - The (persistable) object
public Set getManagedObjects()
getManagedObjects in interface ExecutionContextpublic Set getManagedObjects(Class[] classes)
getManagedObjects in interface ExecutionContextclasses - Classes that we want the enlisted objects for
public Set getManagedObjects(String[] states)
getManagedObjects in interface ExecutionContextstates - States that we want the enlisted objects for
public Set getManagedObjects(String[] states,
Class[] classes)
getManagedObjects in interface ExecutionContextstates - States that we want the enlisted objects forclasses - Classes that we want the enlisted objects for
public Object findObject(Object id,
FieldValues fv,
Class cls,
boolean ignoreCache,
boolean checkInheritance)
findObject in interface ExecutionContextid - Id of the object.fv - Field values for the object (to copy in)cls - the type which the object is (optional). Used to instantiate the objectignoreCache - true if it must ignore the cachecheckInheritance - Whether to check the inheritance on the id of the object
public Object[] findObjects(Object[] identities,
boolean validate)
findObjects in interface ExecutionContextidentities - Ids of the object(s).validate - Whether to validate the object state
NucleusObjectNotFoundException - if an object doesn't exist in the datastore
public Object findObject(Object id,
boolean validate,
boolean checkInheritance,
String objectClassName)
findObject in interface ExecutionContextid - Id of the object.validate - Whether to validate the object statecheckInheritance - Whether look to the database to determine which class this object is.objectClassName - Class name for the object with this id (if known, optional)
NucleusObjectNotFoundException - if the object doesn't exist in the datastore
public Object newObjectId(Class pcClass,
Object key)
newObjectId in interface ExecutionContextpcClass - Class of the PersistenceCapable to create the identity forkey - Value of the key for SingleFieldIdentity (or the toString value)
public Object newObjectId(String className,
Object pc)
newObjectId in interface ExecutionContextclassName - Name of the class of the object.pc - The persistable object. Used for application-identity
public void clearDirty(ObjectProvider op)
clearDirty in interface ExecutionContextop - The ObjectProviderpublic void clearDirty()
clearDirty in interface ExecutionContext
public void markDirty(ObjectProvider op,
boolean directUpdate)
markDirty in interface ExecutionContextop - ObjectProviderdirectUpdate - Whether the object has had a direct update made on it (if known)public boolean getManageRelations()
getManageRelations in interface ExecutionContextpublic boolean getManageRelationsChecks()
public RelationshipManager getRelationshipManager(ObjectProvider op)
ExecutionContext
getRelationshipManager in interface ExecutionContextop - ObjectProvider
public boolean isManagingRelations()
isManagingRelations in interface ExecutionContextprotected void performManagedRelationships()
NucleusUserException - if a consistency check failspublic List<ObjectProvider> getObjectsToBeFlushed()
getObjectsToBeFlushed in interface ExecutionContextpublic boolean isFlushing()
isFlushing in interface ExecutionContextpublic void flush()
flush in interface ExecutionContextpublic void flushInternal(boolean flushToDatastore)
flushInternal in interface ExecutionContextflushToDatastore - 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 datastore
NucleusOptimisticException - when optimistic locking error(s) occurprotected List<NucleusOptimisticException> flushInternalWithOrdering()
protected List<NucleusOptimisticException> flushInternalNonReferential()
public void postBegin()
public void preCommit()
public boolean isObjectModifiedInTransaction(Object id)
isObjectModifiedInTransaction in interface ExecutionContextid - The identity
public boolean isRunningDetachAllOnCommit()
isRunningDetachAllOnCommit in interface ExecutionContextpublic void postCommit()
public void preRollback()
public void postRollback()
public void putObjectIntoLevel1Cache(ObjectProvider op)
putObjectIntoLevel1Cache in interface ExecutionContextop - The ObjectProvider
protected void putObjectIntoLevel2Cache(ObjectProvider op,
boolean updateIfPresent)
op - ObjectProvider for the objectupdateIfPresent - Whether to update it in the L2 cache if already presentprotected CachedPC getL2CacheableObject(ObjectProvider op)
op - ObjectProvider for the object
protected void putObjectsIntoLevel2Cache(Set<ObjectProvider> ops)
ops - The ObjectProviders whose objects are to be cached
protected void putObjectIntoLevel2CacheInternal(ObjectProvider op,
boolean updateIfPresent)
op - ObjectProvider of the object to add.updateIfPresent - Whether to update the L2 cache if it is presentpublic void removeObjectFromLevel1Cache(Object id)
removeObjectFromLevel1Cache in interface ExecutionContextid - The Persistable object idpublic void removeObjectFromLevel2Cache(Object id)
removeObjectFromLevel2Cache in interface ExecutionContextid - Identity of the objectpublic boolean hasIdentityInCache(Object id)
hasIdentityInCache in interface ExecutionContextid - The identity
public Object getObjectFromCache(Object id)
getObjectFromCache in interface ExecutionContextid - Id of the object
public Object getObjectFromLevel1Cache(Object id)
id - Id of the object
public Object getObjectFromLevel2Cache(Object id)
id - Id of the object
protected Map getObjectsFromLevel2Cache(Collection ids)
ids - Collection of ids to retrieve
public void replaceObjectId(Object pc,
Object oldID,
Object newID)
replaceObjectId in interface ExecutionContextpc - The Persistable objectoldID - the old id it was known bynewID - the new idpublic boolean getSerializeReadForClass(String className)
getSerializeReadForClass in interface ExecutionContextclassName - Name of the class
public Extent getExtent(Class pcClass,
boolean subclasses)
getExtent in interface ExecutionContextpcClass - The class to querysubclasses - Whether to include subclasses in the query.
public Query newQuery()
newQuery in interface ExecutionContextpublic void removeAllInstanceLifecycleListeners()
public CallbackHandler getCallbackHandler()
getCallbackHandler in interface ExecutionContext
public void addListener(Object listener,
Class[] classes)
addListener in interface ExecutionContextlistener - The listener to sends events toclasses - The classes that it is interested inpublic void removeListener(Object listener)
removeListener in interface ExecutionContextlistener - The listener to remove.public void disconnectLifecycleListener()
disconnectLifecycleListener in interface ExecutionContextprotected void assertIsOpen()
public void assertClassPersistable(Class cls)
assertClassPersistable in interface ExecutionContextcls - The class to check
ClassNotPersistableException - if class is not persistable
NoPersistenceInformationException - if no metadata/annotations are found for classprotected void assertDetachable(Object object)
object - The object to checkprotected void assertNotDetached(Object object)
object - The object to checkprotected void assertActiveTransaction()
protected void assertHasImplementationCreator()
NucleusUserException - if an ImplementationCreator instance does not existpublic boolean hasPersistenceInformationForClass(Class cls)
hasPersistenceInformationForClass in interface ExecutionContextcls - The class to check
protected FetchGroupManager getFetchGroupManager()
public void addInternalFetchGroup(FetchGroup grp)
addInternalFetchGroup in interface ExecutionContextgrp - The groupprotected void removeInternalFetchGroup(FetchGroup grp)
grp - The group
public FetchGroup getInternalFetchGroup(Class cls,
String name)
getInternalFetchGroup in interface ExecutionContextcls - The classname - Name of the group
NucleusUserException - if the class is not persistablepublic Set getFetchGroupsWithName(String name)
getFetchGroupsWithName in interface ExecutionContextname - Name of the group
public Lock getLock()
getLock in interface ExecutionContext
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||