public class IdentityMapManager extends Object implements Serializable, Cloneable
Purpose: Maintain identity maps for domain classes mapped with TopLink.
Responsibilities:
Modifier and Type | Field and Description |
---|---|
protected ConcurrencyManager |
cacheMutex
Ensure mutual exclusion depending on the cache isolation.
|
protected Hashtable |
identityMaps
A table of identity maps with the key being the domain Class.
|
protected Boolean |
isCacheAccessPreCheckRequired
PERF: Used to avoid readLock and profiler checks to improve performance.
|
protected IdentityMap |
lastAccessedIdentityMap
Optimize the object retrival from the identity map.
|
protected Class |
lastAccessedIdentityMapClass |
protected Map |
queryResults
A table of identity maps with the key being the query
|
protected AbstractSession |
session
A reference to the session owning this manager.
|
protected WriteLockManager |
writeLockManager
Used to store the write lock manager used for merging.
|
Constructor and Description |
---|
IdentityMapManager(AbstractSession session) |
Modifier and Type | Method and Description |
---|---|
CacheKey |
acquireDeferredLock(Vector primaryKey,
Class domainClass,
ClassDescriptor descriptor)
Provides access for setting a deferred lock on an object in the IdentityMap.
|
CacheKey |
acquireLock(Vector primaryKey,
Class domainClass,
boolean forMerge,
ClassDescriptor descriptor)
Provides access for setting a concurrency lock on an object in the IdentityMap.
|
CacheKey |
acquireLockNoWait(Vector primaryKey,
Class domainClass,
boolean forMerge,
ClassDescriptor descriptor)
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(Vector primaryKey,
Class domainClass,
ClassDescriptor descriptor)
INTERNAL:
Find the cachekey for the provided primary key and place a readlock on it.
|
CacheKey |
acquireReadLockOnCacheKeyNoWait(Vector primaryKey,
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 |
clearCacheAccessPreCheck()
Clear the cache access pre-check flag, used from session when profiler .
|
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.
|
Object |
clone()
INTERNAL:
Clones itself, used for uow commit and resume on failure.
|
boolean |
containsKey(Vector key,
Class theClass,
ClassDescriptor descriptor) |
Vector |
getAllFromIdentityMap(Expression selectionCriteria,
Class theClass,
Record translationRow,
InMemoryQueryIndirectionPolicy valueHolderPolicy,
boolean shouldReturnInvalidatedObjects)
Query the cache in-memory.
|
CacheKey |
getCacheKeyForObject(Vector primaryKey,
Class myClass,
ClassDescriptor descriptor)
INTERNAL:
Retrieve the cache key for the given identity information
|
ConcurrencyManager |
getCacheMutex()
Return the cache mutex.
|
Vector |
getClassesRegistered()
INTERNAL:
This method is used to get a list of those classes with IdentityMaps in the Session.
|
Object |
getFromIdentityMap(Expression selectionCriteria,
Class theClass,
Record translationRow,
InMemoryQueryIndirectionPolicy valueHolderPolicy,
boolean conforming,
boolean shouldReturnInvalidatedObjects,
ClassDescriptor descriptor) |
Object |
getFromIdentityMap(Object object)
Get the object from the identity map which has the same identity information
as the given object.
|
Object |
getFromIdentityMap(Vector key,
Class theClass,
boolean shouldReturnInvalidatedObjects,
ClassDescriptor descriptor)
Get the object from the identity map which has the given primary key and class
Only return the object if it has not Invalidated
|
Object |
getFromIdentityMap(Vector key,
Class theClass,
ClassDescriptor descriptor)
Get the object from the identity map which has the given primary key and class
|
Object |
getFromIdentityMapWithDeferredLock(Vector key,
Class theClass,
boolean shouldReturnInvalidatedObjects,
ClassDescriptor descriptor)
Get the object from the cache with the given primary key and class
do not return the object if it was invalidated
|
IdentityMap |
getIdentityMap(ClassDescriptor descriptor)
INTERNAL: (public to allow test cases to check)
Return the identity map for the class, if missing create a new one.
|
Enumeration |
getIdentityMapClasses()
INTERNAL:
|
protected Hashtable |
getIdentityMaps() |
protected Vector |
getKey(Object domainObject) |
protected AbstractSession |
getSession() |
Object |
getWrapper(Vector primaryKey,
Class theClass)
Get the wrapper object from the cache key associated with the given primary key,
this is used for EJB.
|
WriteLockManager |
getWriteLockManager()
INTERNAL:
Returns the single write Lock manager for this session
|
Object |
getWriteLockValue(Vector primaryKey,
Class domainClass,
ClassDescriptor descriptor)
Retrieve the write lock value of the cache key associated with the given primary key,
|
void |
initializeIdentityMap(Class theClass)
Reset the identity map for only the instances of the class.
|
void |
initializeIdentityMaps() |
protected boolean |
isCacheAccessPreCheckRequired()
PERF: Used to micro optimize cache access.
|
void |
printIdentityMap(Class businessClass)
INTERNAL:
Used to print all the objects in the identity map of the passed in class.
|
void |
printIdentityMaps()
INTERNAL:
Used to print all the objects in every identity map in this session.
|
void |
printLocks()
INTERNAL:
Used to print all the Locks in every identity map in this session.
|
void |
printLocks(Class theClass)
INTERNAL:
Used to print all the Locks in the specified identity map in this session.
|
CacheKey |
putInIdentityMap(Object domainObject,
Vector keys,
Object writeLockValue,
long readTime,
ClassDescriptor descriptor)
Register the object with the identity map.
|
protected void |
releaseReadLock()
Read-release the local-map and the entire cache.
|
void |
releaseWriteLock()
Lock the entire cache if the cache isolation requires.
|
Object |
removeFromIdentityMap(Vector key,
Class domainClass,
ClassDescriptor descriptor)
Remove the object from the object cache.
|
protected void |
setCacheMutex(ConcurrencyManager cacheMutex)
Set the cache mutex.
|
void |
setIdentityMaps(Hashtable identityMaps) |
protected void |
setSession(AbstractSession session) |
void |
setWrapper(Vector primaryKey,
Class theClass,
Object wrapper)
Update the wrapper object the cache key associated with the given primary key,
this is used for EJB.
|
void |
setWriteLockValue(Vector primaryKey,
Class theClass,
Object writeLockValue)
Update the write lock value of the cache key associated with the given primary key,
|
protected Hashtable identityMaps
protected Map queryResults
protected AbstractSession session
protected transient ConcurrencyManager cacheMutex
protected IdentityMap lastAccessedIdentityMap
protected Class lastAccessedIdentityMapClass
protected transient WriteLockManager writeLockManager
protected Boolean isCacheAccessPreCheckRequired
public IdentityMapManager(AbstractSession session)
public CacheKey acquireDeferredLock(Vector primaryKey, Class domainClass, ClassDescriptor descriptor)
public CacheKey acquireLock(Vector primaryKey, Class domainClass, boolean forMerge, ClassDescriptor descriptor)
IdentityMap#aquire
public CacheKey acquireLockNoWait(Vector primaryKey, Class domainClass, boolean forMerge, ClassDescriptor descriptor)
IdentityMap#aquire
protected boolean isCacheAccessPreCheckRequired()
public void clearCacheAccessPreCheck()
public void acquireReadLock()
IdentityMap#aquire
public CacheKey acquireReadLockOnCacheKey(Vector primaryKey, Class domainClass, ClassDescriptor descriptor)
public CacheKey acquireReadLockOnCacheKeyNoWait(Vector primaryKey, Class domainClass, ClassDescriptor descriptor)
public boolean acquireWriteLock()
public IdentityMap buildNewIdentityMap(ClassDescriptor descriptor) throws ValidationException, DescriptorException
public void clearLastAccessedIdentityMap()
public Object clone()
public void clearQueryCache()
public void clearQueryCache(ReadQuery query)
public boolean containsKey(Vector key, Class theClass, ClassDescriptor descriptor)
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean shouldReturnInvalidatedObjects)
public CacheKey getCacheKeyForObject(Vector primaryKey, Class myClass, ClassDescriptor descriptor)
Vector
- the primary key of the cache key to be retrievedClass
- the class of the cache key to be retrievedpublic ConcurrencyManager getCacheMutex()
public Vector getClassesRegistered()
public Object getFromIdentityMap(Object object)
public Object getFromIdentityMap(Vector key, Class theClass, ClassDescriptor descriptor)
public Object getFromIdentityMap(Vector key, Class theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor)
public Object getFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor)
public Object getFromIdentityMapWithDeferredLock(Vector key, Class theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor)
public IdentityMap getIdentityMap(ClassDescriptor descriptor)
protected Hashtable getIdentityMaps()
public Enumeration getIdentityMapClasses()
protected AbstractSession getSession()
public Object getWrapper(Vector primaryKey, Class theClass)
public WriteLockManager getWriteLockManager()
public Object getWriteLockValue(Vector primaryKey, Class domainClass, ClassDescriptor descriptor)
public void initializeIdentityMap(Class theClass) throws TopLinkException
TopLinkException
public void initializeIdentityMaps()
public void printIdentityMap(Class businessClass)
public void printIdentityMaps()
public void printLocks()
public void printLocks(Class theClass)
public CacheKey putInIdentityMap(Object domainObject, Vector keys, Object writeLockValue, long readTime, ClassDescriptor descriptor)
protected void releaseReadLock()
public void releaseWriteLock()
public Object removeFromIdentityMap(Vector key, Class domainClass, ClassDescriptor descriptor)
protected void setCacheMutex(ConcurrencyManager cacheMutex)
public void setIdentityMaps(Hashtable identityMaps)
protected void setSession(AbstractSession session)
public void setWrapper(Vector primaryKey, Class theClass, Object wrapper)
Copyright © 2024. All rights reserved.