Module org.eclipse.persistence.core
Class IsolatedClientSessionIdentityMapAccessor
java.lang.Object
org.eclipse.persistence.internal.sessions.IdentityMapAccessor
org.eclipse.persistence.internal.sessions.IsolatedClientSessionIdentityMapAccessor
- All Implemented Interfaces:
Serializable
,IdentityMapAccessor
INTERNAL:
Internal subclass that provides access to identity maps through the session.
Implements the IdentityMapAccessor interface which provides all publicly available
identity map functionality to users.
This is the main class that should be used to access identity maps. In general, any
function that accesses the identity map manager should go through this class
Any session specific functionality appears in subclasses
- See Also:
-
Field Summary
FieldsFields inherited from class org.eclipse.persistence.internal.sessions.IdentityMapAccessor
identityMapManager, session
-
Constructor Summary
ConstructorsConstructorDescriptionINTERNAL: An IdentityMapAccessor sits between the session and the identityMapManager It needs references in both directions -
Method Summary
Modifier and TypeMethodDescriptionacquireDeferredLock
(Object primaryKey, Class<?> javaClass, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Deferred lock the identity map for the object, this is used for avoiding deadlock The return cacheKey should be used to release the deferred lockacquireLock
(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap.acquireLockNoWait
(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap.acquireLockWithWait
(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor, int wait) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap.acquireReadLockOnCacheKey
(Object primaryKey, Class<?> domainClass, ClassDescriptor descriptor) INTERNAL: Find the cachekey for the provided primary key and place a readlock on it.acquireReadLockOnCacheKeyNoWait
(Object primaryKey, Class<?> domainClass, ClassDescriptor descriptor) INTERNAL: Find the cachekey for the provided primary key and place a readlock on it.boolean
INTERNAL: Lock the entire cache if the cache isolation requires.boolean
containsObjectInIdentityMap
(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) ADVANCED: Return if their is an object for the primary key.getAllFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects) ADVANCED: Query the cache in-memory.protected Object
getAndCloneCacheKeyFromParent
(Object primaryKey, Object objectToClone, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) getCacheKeyByIndex
(CacheIndex index, CacheId indexValues, boolean shouldCheckExpiry, ClassDescriptor descriptor) Return the cache key for the cache index or null if not found.getCacheKeyForObject
(Object primaryKey, Class<?> myClass, ClassDescriptor descriptor, boolean forMerge) INTERNAL: Retrieve the cache key for the given identity information.getCacheKeyForObjectForLock
(Object primaryKey, Class<?> myClass, ClassDescriptor descriptor) INTERNAL: Retrieve the cache key for the given identity information.INTERNAL: This method is used to get a list of those classes with IdentityMaps in the Session.getFromIdentityMap
(Object primaryKey, Object object, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) ADVANCED: Return the object from the identity with the primary and class.getFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Query the cache in-memory.getFromIdentityMapWithDeferredLock
(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the identity with the primary and class.getFromLocalIdentityMap
(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the local identity map with the primary and class.getIdentityMap
(ClassDescriptor descriptor, boolean returnNullIfMissing) INTERNAL: Get the identity map for the given class from the IdentityMapManagerINTERNAL: Get the IdentityMapManager for this IdentityMapAccessor This method should be used for all IdentityMapManager access since it may be overridden in sub classes.getQueryResult
(ReadQuery query, List parameters, boolean checkExpiry) INTERNAL: Get the cached results associated with a query.INTERNAL: get the session associated with this IdentityMapAccessorgetWrapper
(Object primaryKey, Class<?> theClass) INTERNAL: Get the wrapper object from the cache key associated with the given primary key, this is used for EJB.INTERNAL: Returns the single write Lock manager for this sessiongetWriteLockValue
(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) ADVANCED: Extract the write lock value from the identity map.void
PUBLIC: Reset the entire object cache.void
initializeIdentityMap
(Class<?> theClass) PUBLIC: Reset the identity map for only the instances of the class.void
PUBLIC: Reset the entire local object cache.internalPutInIdentityMap
(Object domainObject, Object key, Object writeLockValue, long readTime, ClassDescriptor descriptor) ADVANCED: Register the object with the identity map.void
invalidateObjects
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, boolean shouldInvalidateOnException) ADVANCED: Queries the cache in-memory with the passed in criteria and invalidates matching Objects.void
invalidateQueryCache
(Class<?> classThatChanged) Invalidate/remove any results for the class from the query cache.void
printIdentityMap
(Class<?> businessClass) PUBLIC: Used to print all the objects in the identity map of the passed in class.void
PUBLIC: Used to print all the locks in every identity map in this session.void
PUBLIC: Used to print all the objects in every identity map in this session.void
putCacheKeyByIndex
(CacheIndex index, CacheId indexValues, CacheKey cacheKey, ClassDescriptor descriptor) Index the cache key by the index values.void
putQueryResult
(ReadQuery query, List parameters, Object results) INTERNAL: Set the results for a query.void
INTERNAL: Lock the entire cache if the cache isolation requires.removeFromIdentityMap
(Object key, Class<?> theClass, ClassDescriptor descriptor, Object object) ADVANCED: Remove the object from the object cache.void
setIdentityMapManager
(IdentityMapManager identityMapManager) INTERNAL: Set the IdentityMapManager for this IdentityMapAccessorvoid
setWrapper
(Object primaryKey, Class<?> theClass, Object wrapper) INTERNAL: Update the wrapper object the cache key associated with the given primary key, this is used for EJB.void
updateWriteLockValue
(Object primaryKey, Class<?> theClass, Object writeLockValue) ADVANCED: Update the write lock value in the identity map.Methods inherited from class org.eclipse.persistence.internal.sessions.IdentityMapAccessor
acquireLock, clearQueryCache, clearQueryCache, clearQueryCache, clearQueryCache, containsObjectInIdentityMap, containsObjectInIdentityMap, containsObjectInIdentityMap, extractPrimaryKeyFromRow, getAllCacheKeysFromIdentityMapWithEntityPK, getAllFromIdentityMap, getAllFromIdentityMap, getAllFromIdentityMap, getAllFromIdentityMap, getAllFromIdentityMapWithEntityPK, getCacheKeyForObject, getCacheKeyForObject, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMap, getFromIdentityMapWithDeferredLock, getFromLocalIdentityMapWithDeferredLock, getIdentityMap, getIdentityMap, getRemainingValidTime, getWriteLockValue, getWriteLockValue, invalidateAll, invalidateClass, invalidateClass, invalidateObject, invalidateObject, invalidateObject, invalidateObject, invalidateObject, invalidateObject, invalidateObjects, invalidateObjects, invalidateObjects, isValid, isValid, isValid, putInIdentityMap, putInIdentityMap, putInIdentityMap, putInIdentityMap, putInIdentityMap, removeFromIdentityMap, removeFromIdentityMap, updateWriteLockValue, validateCache
-
Field Details
-
objectsLockedForClone
-
-
Constructor Details
-
IsolatedClientSessionIdentityMapAccessor
INTERNAL: An IdentityMapAccessor sits between the session and the identityMapManager It needs references in both directions
-
-
Method Details
-
acquireDeferredLock
public CacheKey acquireDeferredLock(Object primaryKey, Class<?> javaClass, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Deferred lock the identity map for the object, this is used for avoiding deadlock The return cacheKey should be used to release the deferred lock- Overrides:
acquireDeferredLock
in classIdentityMapAccessor
-
acquireLock
public CacheKey acquireLock(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap. called with true from the merge process, if true then the refresh will not refresh the object.- Overrides:
acquireLock
in classIdentityMapAccessor
-
acquireLockNoWait
public CacheKey acquireLockNoWait(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap. called with true from the merge process, if true then the refresh will not refresh the object.- Overrides:
acquireLockNoWait
in classIdentityMapAccessor
-
acquireLockWithWait
public CacheKey acquireLockWithWait(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor, int wait) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap. called with true from the merge process, if true then the refresh will not refresh the object.- Overrides:
acquireLockWithWait
in classIdentityMapAccessor
-
acquireReadLockOnCacheKey
public CacheKey acquireReadLockOnCacheKey(Object primaryKey, Class<?> domainClass, ClassDescriptor descriptor) INTERNAL: Find the cachekey for the provided primary key and place a readlock on it. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held.- Overrides:
acquireReadLockOnCacheKey
in classIdentityMapAccessor
-
acquireReadLockOnCacheKeyNoWait
public CacheKey acquireReadLockOnCacheKeyNoWait(Object primaryKey, Class<?> domainClass, ClassDescriptor descriptor) INTERNAL: Find the cachekey for the provided primary key and place a readlock on it. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held. If no readlock can be acquired then do not wait but return null.- Overrides:
acquireReadLockOnCacheKeyNoWait
in classIdentityMapAccessor
-
acquireWriteLock
public boolean acquireWriteLock()INTERNAL: Lock the entire cache if the cache isolation requires. By default concurrent reads and writes are allowed. By write, unit of work merge is meant.- Overrides:
acquireWriteLock
in classIdentityMapAccessor
-
containsObjectInIdentityMap
public boolean containsObjectInIdentityMap(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) ADVANCED: Return if their is an object for the primary key.- Overrides:
containsObjectInIdentityMap
in classIdentityMapAccessor
-
getClassesRegistered
INTERNAL: This method is used to get a list of those classes with IdentityMaps in the Session.- Overrides:
getClassesRegistered
in classIdentityMapAccessor
-
getAllFromIdentityMap
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects) throws QueryException ADVANCED: Query the cache in-memory. If the expression is too complex an exception will be thrown. Only return objects that are invalid in the cache if specified.- Specified by:
getAllFromIdentityMap
in interfaceIdentityMapAccessor
- Overrides:
getAllFromIdentityMap
in classIdentityMapAccessor
- Parameters:
selectionCriteria
- Expression selecting the Objects to be returnedtheClass
- Class to be consideredtranslationRow
- RecordvalueHolderPolicy
- seeInMemoryQueryIndirectionPolicy
shouldReturnInvalidatedObjects
- boolean - true if only invalid Objects should be returned- Returns:
- Vector of Objects
- Throws:
QueryException
-
getCacheKeyForObject
public CacheKey getCacheKeyForObject(Object primaryKey, Class<?> myClass, ClassDescriptor descriptor, boolean forMerge) INTERNAL: Retrieve the cache key for the given identity information.- Overrides:
getCacheKeyForObject
in classIdentityMapAccessor
- Parameters:
primaryKey
- the primary key of the cache key to be retrieved.myClass
- the class of the cache key to be retrieved.
-
getCacheKeyForObjectForLock
public CacheKey getCacheKeyForObjectForLock(Object primaryKey, Class<?> myClass, ClassDescriptor descriptor) INTERNAL: Retrieve the cache key for the given identity information.- Overrides:
getCacheKeyForObjectForLock
in classIdentityMapAccessor
- Parameters:
primaryKey
- the primary key of the cache key to be retrieved.myClass
- the class of the cache key to be retrieved.
-
getFromIdentityMap
public Object getFromIdentityMap(Object primaryKey, Object object, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) ADVANCED: Return the object from the identity with the primary and class.- Overrides:
getFromIdentityMap
in classIdentityMapAccessor
-
getAndCloneCacheKeyFromParent
protected Object getAndCloneCacheKeyFromParent(Object primaryKey, Object objectToClone, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) -
getFromLocalIdentityMap
public Object getFromLocalIdentityMap(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the local identity map with the primary and class. This avoids checking the parent cache for the unit of work.- Overrides:
getFromLocalIdentityMap
in classIdentityMapAccessor
-
getFromIdentityMap
public Object getFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Query the cache in-memory. If the object is not found null is returned. If the expression is too complex an exception will be thrown.- Overrides:
getFromIdentityMap
in classIdentityMapAccessor
-
getFromIdentityMapWithDeferredLock
public Object getFromIdentityMapWithDeferredLock(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the identity with the primary and class. Only return invalidated objects if requested- Overrides:
getFromIdentityMapWithDeferredLock
in classIdentityMapAccessor
-
getIdentityMapManager
INTERNAL: Get the IdentityMapManager for this IdentityMapAccessor This method should be used for all IdentityMapManager access since it may be overridden in sub classes.- Overrides:
getIdentityMapManager
in classIdentityMapAccessor
-
getIdentityMap
INTERNAL: Get the identity map for the given class from the IdentityMapManager- Overrides:
getIdentityMap
in classIdentityMapAccessor
-
getQueryResult
INTERNAL: Get the cached results associated with a query. Results are cached by the values of the parameters to the query so different parameters will have different cached results.- Overrides:
getQueryResult
in classIdentityMapAccessor
-
getSession
INTERNAL: get the session associated with this IdentityMapAccessor- Overrides:
getSession
in classIdentityMapAccessor
-
getWrapper
INTERNAL: Get the wrapper object from the cache key associated with the given primary key, this is used for EJB.- Overrides:
getWrapper
in classIdentityMapAccessor
-
getWriteLockManager
INTERNAL: Returns the single write Lock manager for this session- Overrides:
getWriteLockManager
in classIdentityMapAccessor
-
getWriteLockValue
ADVANCED: Extract the write lock value from the identity map.- Overrides:
getWriteLockValue
in classIdentityMapAccessor
-
initializeAllIdentityMaps
public void initializeAllIdentityMaps()PUBLIC: Reset the entire object cache.NOTE: be careful using this method. This method blows away both this session's and its parents caches, this includes the server cache or any other cache. This throws away any objects that have been read in. Extream caution should be used before doing this because object identity will no longer be maintained for any objects currently read in. This should only be called if the application knows that it no longer has references to object held in the cache.
- Specified by:
initializeAllIdentityMaps
in interfaceIdentityMapAccessor
- Overrides:
initializeAllIdentityMaps
in classIdentityMapAccessor
-
initializeIdentityMap
PUBLIC: Reset the identity map for only the instances of the class. For inheritance the user must make sure that they only use the root class. Caution must be used in doing this to ensure that the objects within the identity map are not referenced from other objects of other classes or from the application.- Specified by:
initializeIdentityMap
in interfaceIdentityMapAccessor
- Overrides:
initializeIdentityMap
in classIdentityMapAccessor
- Parameters:
theClass
- Class
-
invalidateQueryCache
Invalidate/remove any results for the class from the query cache. This is used to invalidate the query cache on any change.- Specified by:
invalidateQueryCache
in interfaceIdentityMapAccessor
- Overrides:
invalidateQueryCache
in classIdentityMapAccessor
-
initializeIdentityMaps
public void initializeIdentityMaps()PUBLIC: Reset the entire local object cache. This throws away any objects that have been read in. Extreme caution should be used before doing this because object identity will no longer be maintained for any objects currently read in. This should only be called if the application knows that it no longer has references to object held in the cache.- Specified by:
initializeIdentityMaps
in interfaceIdentityMapAccessor
- Overrides:
initializeIdentityMaps
in classIdentityMapAccessor
-
putQueryResult
INTERNAL: Set the results for a query. Query results are cached based on the parameter values provided to the query different parameter values access different caches.- Overrides:
putQueryResult
in classIdentityMapAccessor
-
putCacheKeyByIndex
public void putCacheKeyByIndex(CacheIndex index, CacheId indexValues, CacheKey cacheKey, ClassDescriptor descriptor) Index the cache key by the index values.- Overrides:
putCacheKeyByIndex
in classIdentityMapAccessor
-
getCacheKeyByIndex
public CacheKey getCacheKeyByIndex(CacheIndex index, CacheId indexValues, boolean shouldCheckExpiry, ClassDescriptor descriptor) Return the cache key for the cache index or null if not found.- Overrides:
getCacheKeyByIndex
in classIdentityMapAccessor
-
printIdentityMap
PUBLIC: Used to print all the objects in the identity map of the passed in class. The output of this method will be logged to this session's SessionLog at SEVERE level.- Specified by:
printIdentityMap
in interfaceIdentityMapAccessor
- Overrides:
printIdentityMap
in classIdentityMapAccessor
-
printIdentityMaps
public void printIdentityMaps()PUBLIC: Used to print all the objects in every identity map in this session. The output of this method will be logged to this session's SessionLog at SEVERE level.- Specified by:
printIdentityMaps
in interfaceIdentityMapAccessor
- Overrides:
printIdentityMaps
in classIdentityMapAccessor
-
printIdentityMapLocks
public void printIdentityMapLocks()PUBLIC: Used to print all the locks in every identity map in this session. The output of this method will be logged to this session's SessionLog at FINEST level.- Specified by:
printIdentityMapLocks
in interfaceIdentityMapAccessor
- Overrides:
printIdentityMapLocks
in classIdentityMapAccessor
-
internalPutInIdentityMap
public CacheKey internalPutInIdentityMap(Object domainObject, Object key, Object writeLockValue, long readTime, ClassDescriptor descriptor) ADVANCED: Register the object with the identity map. The object must always be registered with its version number if optimistic locking is used. The readTime may also be included in the cache key as it is constructed.- Overrides:
internalPutInIdentityMap
in classIdentityMapAccessor
-
invalidateObjects
public void invalidateObjects(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, boolean shouldInvalidateOnException) ADVANCED: Queries the cache in-memory with the passed in criteria and invalidates matching Objects. If the expression is too complex either all or none object of theClass invalidated (depending on shouldInvalidateOnException value).- Specified by:
invalidateObjects
in interfaceIdentityMapAccessor
- Overrides:
invalidateObjects
in classIdentityMapAccessor
- Parameters:
selectionCriteria
- Expression selecting the Objects to be returnedtheClass
- Class to be consideredtranslationRow
- RecordshouldInvalidateOnException
- boolean indicates weather to invalidate the object if conform threw exception.
-
releaseWriteLock
public void releaseWriteLock()INTERNAL: Lock the entire cache if the cache isolation requires. By default concurrent reads and writes are allowed. By write, unit of work merge is meant.- Overrides:
releaseWriteLock
in classIdentityMapAccessor
-
removeFromIdentityMap
public Object removeFromIdentityMap(Object key, Class<?> theClass, ClassDescriptor descriptor, Object object) ADVANCED: Remove the object from the object cache.- Overrides:
removeFromIdentityMap
in classIdentityMapAccessor
-
setIdentityMapManager
INTERNAL: Set the IdentityMapManager for this IdentityMapAccessor- Overrides:
setIdentityMapManager
in classIdentityMapAccessor
-
setWrapper
INTERNAL: Update the wrapper object the cache key associated with the given primary key, this is used for EJB.- Overrides:
setWrapper
in classIdentityMapAccessor
-
updateWriteLockValue
ADVANCED: Update the write lock value in the identity map.- Specified by:
updateWriteLockValue
in interfaceIdentityMapAccessor
- Overrides:
updateWriteLockValue
in classIdentityMapAccessor
-