public class IdentityMapManager
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Purpose: Maintain identity maps for domain classes mapped with EclipseLink.
Responsibilities:
Constructor and Description |
---|
IdentityMapManager(AbstractSession session) |
Modifier and Type | Method and Description |
---|---|
CacheKey |
acquireDeferredLock(java.lang.Object primaryKey,
java.lang.Class domainClass,
ClassDescriptor descriptor,
boolean isCacheCheckComplete)
Provides access for setting a deferred lock on an object in the IdentityMap.
|
CacheKey |
acquireLock(java.lang.Object primaryKey,
java.lang.Class domainClass,
boolean forMerge,
ClassDescriptor descriptor,
boolean isCacheCheckComplete)
Provides access for setting a concurrency lock on an object in the IdentityMap.
|
CacheKey |
acquireLockNoWait(java.lang.Object primaryKey,
java.lang.Class domainClass,
boolean forMerge,
ClassDescriptor descriptor)
Provides access for setting a concurrency lock on an object in the IdentityMap.
|
CacheKey |
acquireLockWithWait(java.lang.Object primaryKey,
java.lang.Class domainClass,
boolean forMerge,
ClassDescriptor descriptor,
int wait)
Provides access for setting a concurrency lock on an object in the IdentityMap.
|
void |
acquireReadLock()
Provides access for setting a concurrency lock on an IdentityMap.
|
CacheKey |
acquireReadLockOnCacheKey(java.lang.Object primaryKey,
java.lang.Class domainClass,
ClassDescriptor descriptor)
INTERNAL:
Find the cachekey for the provided primary key and place a readlock on it.
|
CacheKey |
acquireReadLockOnCacheKeyNoWait(java.lang.Object primaryKey,
java.lang.Class domainClass,
ClassDescriptor descriptor)
INTERNAL:
Find the cachekey for the provided primary key and place a readlock on it.
|
boolean |
acquireWriteLock()
Lock the entire cache if the cache isolation requires.
|
IdentityMap |
buildNewIdentityMap(ClassDescriptor descriptor)
INTERNAL: (Public to allow testing to access)
Return a new empty identity map to cache instances of the class.
|
void |
checkIsCacheAccessPreCheckRequired()
PERF: Used to micro optimize cache access.
|
void |
clearCacheIndexes()
Clear all index caches.
|
void |
clearLastAccessedIdentityMap()
INTERNAL:
Clear the the lastAccessedIdentityMap and the lastAccessedIdentityMapClass
|
void |
clearQueryCache()
Clear all the query caches.
|
void |
clearQueryCache(ReadQuery query)
Remove the cache key related to a query.
|
java.lang.Object |
clone()
INTERNAL:
Clones itself, used for uow commit and resume on failure.
|
boolean |
containsKey(java.lang.Object key,
java.lang.Class theClass,
ClassDescriptor descriptor)
Return true if an CacheKey with the primary key is in the map.
|
java.util.Map<java.lang.Object,CacheKey> |
getAllCacheKeysFromIdentityMapWithEntityPK(java.lang.Object[] pkList,
ClassDescriptor descriptor,
AbstractSession session)
ADVANCED:
Using a list of Entity PK this method will attempt to bulk load the entire list from the cache.
|
java.util.Vector |
getAllFromIdentityMap(Expression selectionCriteria,
java.lang.Class theClass,
Record translationRow,
int valueHolderPolicy,
boolean shouldReturnInvalidatedObjects)
Query the cache in-memory.
|
java.util.Map<java.lang.Object,java.lang.Object> |
getAllFromIdentityMapWithEntityPK(java.lang.Object[] pkList,
ClassDescriptor descriptor,
AbstractSession session)
ADVANCED:
Using a list of Entity PK this method will attempt to bulk load the entire list from the cache.
|
CacheKey |
getCacheKeyByIndex(CacheIndex index,
CacheId indexValues,
boolean shouldCheckExpiry,
ClassDescriptor descriptor)
Return the cache key for the cache index or null if not found.
|
CacheKey |
getCacheKeyForObject(java.lang.Object primaryKey,
java.lang.Class theClass,
ClassDescriptor descriptor,
boolean forMerge)
Retrieve the cache key for the given identity information.
|
CacheKey |
getCacheKeyForObjectForLock(java.lang.Object primaryKey,
java.lang.Class theClass,
ClassDescriptor descriptor)
Retrieve the cache key for the given identity information.
|
ConcurrencyManager |
getCacheMutex()
Return the cache mutex.
|
java.util.Vector |
getClassesRegistered()
This method is used to get a list of those classes with IdentityMaps in the Session.
|
java.lang.Object |
getFromIdentityMap(Expression selectionCriteria,
java.lang.Class theClass,
Record translationRow,
int valueHolderPolicy,
boolean conforming,
boolean shouldReturnInvalidatedObjects,
ClassDescriptor descriptor) |
java.lang.Object |
getFromIdentityMap(java.lang.Object object)
Get the object from the identity map which has the same identity information
as the given object.
|
java.lang.Object |
getFromIdentityMap(java.lang.Object key,
java.lang.Class theClass,
boolean shouldReturnInvalidatedObjects,
ClassDescriptor descriptor)
Get the object from the identity map which has the given primary key and class.
|
java.lang.Object |
getFromIdentityMap(java.lang.Object key,
java.lang.Class theClass,
ClassDescriptor descriptor)
Get the object from the identity map which has the given primary key and class.
|
java.lang.Object |
getFromIdentityMapWithDeferredLock(java.lang.Object key,
java.lang.Class theClass,
boolean shouldReturnInvalidatedObjects,
ClassDescriptor descriptor)
Get the object from the cache with the given primary key and class.
|
IdentityMap |
getIdentityMap(ClassDescriptor descriptor)
INTERNAL:
Return the identity map for the class, if missing create a new one.
|
IdentityMap |
getIdentityMap(ClassDescriptor descriptor,
boolean returnNullIfNoMap)
INTERNAL:
Return the identity map for the class.
|
java.util.Iterator |
getIdentityMapClasses()
Return an iterator of the classes in the identity map.
|
java.lang.Object |
getQueryResult(ReadQuery query,
java.util.List parameters,
boolean shouldCheckExpiry)
Get the cached results associated with a query.
|
java.lang.Object |
getWrapper(java.lang.Object primaryKey,
java.lang.Class theClass)
Get the wrapper object from the cache key associated with the given primary key,
this is used for EJB.
|
WriteLockManager |
getWriteLockManager()
Returns the single write Lock manager for this session
|
java.lang.Object |
getWriteLockValue(java.lang.Object primaryKey,
java.lang.Class domainClass,
ClassDescriptor descriptor)
Retrieve the write lock value of the cache key associated with the given primary key,
|
void |
initializeIdentityMap(java.lang.Class theClass)
Reset the identity map for only the instances of the class.
|
void |
initializeIdentityMaps() |
void |
invalidateObjects(Expression selectionCriteria,
java.lang.Class theClass,
Record translationRow,
boolean shouldInvalidateOnException)
Invalidate objects meeting selectionCriteria.
|
void |
invalidateQueryCache(java.lang.Class classThatChanged)
Invalidate/remove any results for the class from the query cache.
|
void |
printIdentityMap(java.lang.Class businessClass)
Used to print all the objects in the identity map of the passed in class.
|
void |
printIdentityMaps()
Used to print all the objects in every identity map in this session.
|
void |
printLocks()
Used to print all the Locks in every identity map in this session.
|
void |
printLocks(java.lang.Class theClass)
Used to print all the Locks in the specified identity map in this session.
|
void |
putCacheKeyByIndex(CacheIndex index,
CacheId indexValues,
CacheKey cacheKey,
ClassDescriptor descriptor)
Index the cache key by the index values.
|
CacheKey |
putInIdentityMap(java.lang.Object domainObject,
java.lang.Object keys,
java.lang.Object writeLockValue,
long readTime,
ClassDescriptor descriptor)
Register the object with the identity map.
|
void |
putQueryResult(ReadQuery query,
java.util.List parameters,
java.lang.Object results)
Set the results for a query.
|
void |
releaseWriteLock()
Lock the entire cache if the cache isolation requires.
|
java.lang.Object |
removeFromIdentityMap(java.lang.Object key,
java.lang.Class domainClass,
ClassDescriptor descriptor,
java.lang.Object objectToRemove)
Remove the object from the object cache.
|
void |
setIdentityMaps(java.util.concurrent.ConcurrentMap identityMaps) |
void |
setWrapper(java.lang.Object primaryKey,
java.lang.Class theClass,
java.lang.Object wrapper)
Update the wrapper object the cache key associated with the given primary key,
this is used for EJB.
|
void |
setWriteLockValue(java.lang.Object primaryKey,
java.lang.Class theClass,
java.lang.Object writeLockValue)
Update the write lock value of the cache key associated with the given primary key,
|
public IdentityMapManager(AbstractSession session)
public CacheKey acquireDeferredLock(java.lang.Object primaryKey, java.lang.Class domainClass, ClassDescriptor descriptor, boolean isCacheCheckComplete)
public CacheKey acquireLock(java.lang.Object primaryKey, java.lang.Class domainClass, boolean forMerge, ClassDescriptor descriptor, boolean isCacheCheckComplete)
public CacheKey acquireLockNoWait(java.lang.Object primaryKey, java.lang.Class domainClass, boolean forMerge, ClassDescriptor descriptor)
public CacheKey acquireLockWithWait(java.lang.Object primaryKey, java.lang.Class domainClass, boolean forMerge, ClassDescriptor descriptor, int wait)
public void checkIsCacheAccessPreCheckRequired()
public void acquireReadLock()
public CacheKey acquireReadLockOnCacheKey(java.lang.Object primaryKey, java.lang.Class domainClass, ClassDescriptor descriptor)
public CacheKey acquireReadLockOnCacheKeyNoWait(java.lang.Object primaryKey, java.lang.Class domainClass, ClassDescriptor descriptor)
public boolean acquireWriteLock()
public IdentityMap buildNewIdentityMap(ClassDescriptor descriptor)
public void clearLastAccessedIdentityMap()
public java.lang.Object clone()
clone
in class java.lang.Object
public void clearQueryCache()
public void clearCacheIndexes()
public void clearQueryCache(ReadQuery query)
public void invalidateQueryCache(java.lang.Class classThatChanged)
public boolean containsKey(java.lang.Object key, java.lang.Class theClass, ClassDescriptor descriptor)
key
- is the primary key for the object to search for.public java.util.Vector getAllFromIdentityMap(Expression selectionCriteria, java.lang.Class theClass, Record translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects)
public java.util.Map<java.lang.Object,java.lang.Object> getAllFromIdentityMapWithEntityPK(java.lang.Object[] pkList, ClassDescriptor descriptor, AbstractSession session)
pkList
- List of Entity PKs to extract from the cacheClassDescriptor
- Descriptor type to be retrieved.QueryException
public java.util.Map<java.lang.Object,CacheKey> getAllCacheKeysFromIdentityMapWithEntityPK(java.lang.Object[] pkList, ClassDescriptor descriptor, AbstractSession session)
pkList
- List of Entity PKs to extract from the cacheClassDescriptor
- Descriptor type to be retrieved.QueryException
public void invalidateObjects(Expression selectionCriteria, java.lang.Class theClass, Record translationRow, boolean shouldInvalidateOnException)
public CacheKey getCacheKeyForObjectForLock(java.lang.Object primaryKey, java.lang.Class theClass, ClassDescriptor descriptor)
public CacheKey getCacheKeyForObject(java.lang.Object primaryKey, java.lang.Class theClass, ClassDescriptor descriptor, boolean forMerge)
public ConcurrencyManager getCacheMutex()
public java.util.Vector getClassesRegistered()
public java.lang.Object getFromIdentityMap(java.lang.Object object)
public java.lang.Object getFromIdentityMap(java.lang.Object key, java.lang.Class theClass, ClassDescriptor descriptor)
public java.lang.Object getFromIdentityMap(java.lang.Object key, java.lang.Class theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor)
public java.lang.Object getFromIdentityMap(Expression selectionCriteria, java.lang.Class theClass, Record translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor)
public java.lang.Object getFromIdentityMapWithDeferredLock(java.lang.Object key, java.lang.Class theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor)
public IdentityMap getIdentityMap(ClassDescriptor descriptor)
public IdentityMap getIdentityMap(ClassDescriptor descriptor, boolean returnNullIfNoMap)
returnNullIfNoMap
- if true return null if no map, otherwise create one.public java.util.Iterator getIdentityMapClasses()
public java.lang.Object getQueryResult(ReadQuery query, java.util.List parameters, boolean shouldCheckExpiry)
public CacheKey getCacheKeyByIndex(CacheIndex index, CacheId indexValues, boolean shouldCheckExpiry, ClassDescriptor descriptor)
public void putCacheKeyByIndex(CacheIndex index, CacheId indexValues, CacheKey cacheKey, ClassDescriptor descriptor)
public java.lang.Object getWrapper(java.lang.Object primaryKey, java.lang.Class theClass)
public WriteLockManager getWriteLockManager()
public java.lang.Object getWriteLockValue(java.lang.Object primaryKey, java.lang.Class domainClass, ClassDescriptor descriptor)
public void initializeIdentityMap(java.lang.Class theClass) throws EclipseLinkException
EclipseLinkException
public void initializeIdentityMaps()
public void printIdentityMap(java.lang.Class businessClass)
public void printIdentityMaps()
public void printLocks()
public void printLocks(java.lang.Class theClass)
public CacheKey putInIdentityMap(java.lang.Object domainObject, java.lang.Object keys, java.lang.Object writeLockValue, long readTime, ClassDescriptor descriptor)
public void putQueryResult(ReadQuery query, java.util.List parameters, java.lang.Object results)
public void releaseWriteLock()
public java.lang.Object removeFromIdentityMap(java.lang.Object key, java.lang.Class domainClass, ClassDescriptor descriptor, java.lang.Object objectToRemove)
public void setIdentityMaps(java.util.concurrent.ConcurrentMap identityMaps)
public void setWrapper(java.lang.Object primaryKey, java.lang.Class theClass, java.lang.Object wrapper)
public void setWriteLockValue(java.lang.Object primaryKey, java.lang.Class theClass, java.lang.Object writeLockValue)
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference