Purpose: Caches objects, and allows their retrieval by their primary key.
Responsibilities:
CacheKey
| Modifier and Type | Field and Description |
|---|---|
| protected transient ClassDescriptor | descriptor
PERF: Store the descriptor to allow lastAccessed cache lookup optimization. |
| protected boolean | isIsolated
Is this identity map within an IsolatedClientSession |
| protected int | maxSize
The initial or maximum size of the cache depending upon the concrete implementation. |
| protected AbstractSession | session
Session that the map is on |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | AbstractIdentityMap(int
is the maximum size to be allocated for the receiver. size, ClassDescriptor descriptor, AbstractSession session, boolean isolated)Instantiate an new IdentityMap with it's maximum size. |
| Modifier and Type | Method and Description |
|---|---|
| public CacheKey | acquireDeferredLock(Object primaryKey, boolean isCacheCheckComplete)
Implements org. |
| public CacheKey | acquireLock(Object primaryKey, boolean forMerge, boolean isCacheCheckComplete)
Implements org. |
| public CacheKey | acquireLockNoWait(Object primaryKey, boolean forMerge)
Implements org. |
| public CacheKey | acquireLockWithWait(Object primaryKey, boolean forMerge, int wait)
Implements org. |
| public CacheKey | acquireReadLockOnCacheKey(Object primaryKey)
Implements org. |
| public CacheKey | acquireReadLockOnCacheKeyNoWait(Object primaryKey)
Implements org. |
| public Object | clone()
Overrides java. Implements org. |
| public abstract void | collectLocks(HashMap<K, V> threadList)
Redeclares org. |
| public boolean | containsKey(Object
is the primary key for the object to search for. primaryKey)Implements org. |
| public CacheKey | createCacheKey(Object primaryKey, Object object, Object writeLockValue, long readTime)
Create the correct type of CacheKey for this map. |
| public abstract Enumeration | elements()
Redeclares org. |
| public Object | get(Object primaryKey)
Implements org. |
| public Map | Returns: Map of Entity PKs associated to the Entities that were retrievedList of Entity PKs to extract from the cache pkList, ClassDescriptor Descriptor type to be retrieved. descriptor, AbstractSession session)Implements org. |
| public Map | Returns: Map of Entity PKs associated to the Entities that were retrievedList of Entity PKs to extract from the cache pkList, ClassDescriptor Descriptor type to be retrieved. descriptor, AbstractSession session)Implements org. |
| public abstract CacheKey | getCacheKey(Object primaryKey, boolean forMerge)
Redeclares org. |
| public CacheKey | getCacheKeyForLock(Object primaryKey)
Implements org. |
| protected CacheKey | getCacheKeyWithReadLock(Object primaryKey)
Get the cache key (with object) for the primary key with read lock. |
| public static Class | getDefaultIdentityMapClass()
Returns the class which should be used as an identity map in a descriptor by default. |
| public ClassDescriptor | getDescriptor()
Implements org. |
| public Class | getDescriptorClass()
Implements org. |
| public int | Returns: The maxSize for the IdentityMap (NOTE: some subclasses may use this differently).Implements org. |
| public abstract int | getSize()
Redeclares org. |
| public abstract int | getSize(Class<?> myClass, boolean recurse)
Redeclares org. |
| public Object | getWrapper(Object primaryKey)
Implements org. |
| public Object | getWriteLockValue(Object primaryKey)
Implements org. |
| public abstract Enumeration | keys()
Redeclares org. |
| public abstract CacheKey | put(Object
is the primary key for the object. primaryKey, Object is the domain object to cache. object, Object is the current write lock value of object, if null the version is ignored. writeLockValue, long readTime)Redeclares org. |
| protected abstract CacheKey | |
| public void | release()
Implements org. |
| public Object | remove(Object primaryKey, Object object)
Implements org. |
| public abstract Object | remove(CacheKey cacheKey)
Redeclares org. |
| public void | setDescriptor(ClassDescriptor descriptor)
Implements org. |
| protected synchronized void | |
| public void | setWrapper(Object primaryKey, Object wrapper)
Implements org. |
| public void | setWriteLockValue(Object primaryKey, Object writeLockValue)
Implements org. |
| public String | toString()
Overrides java. Implements org. |
| public void | updateMaxSize(int maxSize)
Implements org. |
| descriptor | back to summary |
|---|---|
| protected transient ClassDescriptor descriptor PERF: Store the descriptor to allow lastAccessed cache lookup optimization. | |
| isIsolated | back to summary |
|---|---|
| protected boolean isIsolated Is this identity map within an IsolatedClientSession | |
| maxSize | back to summary |
|---|---|
| protected int maxSize The initial or maximum size of the cache depending upon the concrete implementation. | |
| session | back to summary |
|---|---|
| protected AbstractSession session Session that the map is on | |
| AbstractIdentityMap | back to summary |
|---|---|
| protected AbstractIdentityMap() | |
| AbstractIdentityMap | back to summary |
|---|---|
| protected AbstractIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated) Instantiate an new IdentityMap with it's maximum size. Note Subclasses may provide different behavior for maxSize.
| |
| acquireDeferredLock | back to summary |
|---|---|
| public CacheKey acquireDeferredLock(Object primaryKey, boolean isCacheCheckComplete) Implements org. Acquire a deferred lock on the object. This is used while reading if the object has relationships without indirection. This first thread will get an active lock. Other threads will get deferred locks, all threads will wait until all other threads are complete before releasing their locks.
| |
| acquireLock | back to summary |
|---|---|
| public CacheKey acquireLock(Object primaryKey, boolean forMerge, boolean isCacheCheckComplete) Implements org. Acquire an active lock on the object. This is used by reading (when using indirection or no relationships) and by merge.
| |
| acquireLockNoWait | back to summary |
|---|---|
| public CacheKey acquireLockNoWait(Object primaryKey, boolean forMerge) Implements org. Acquire an active lock on the object, if not already locked. This is used by merge for missing existing objects.
| |
| acquireLockWithWait | back to summary |
|---|---|
| public CacheKey acquireLockWithWait(Object primaryKey, boolean forMerge, int wait) Implements org. Acquire an active lock on the object, if not already locked. This is used by merge for missing existing objects.
| |
| acquireReadLockOnCacheKey | back to summary |
|---|---|
| public CacheKey acquireReadLockOnCacheKey(Object primaryKey) Implements org. Acquire a read lock on the object. This is used by UnitOfWork cloning. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held.
| |
| acquireReadLockOnCacheKeyNoWait | back to summary |
|---|---|
| public CacheKey acquireReadLockOnCacheKeyNoWait(Object primaryKey) Implements org. Acquire a read lock on the object, if not already locked. This is used by UnitOfWork cloning. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held.
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Implements org. Clone the map and all of the CacheKeys. This is used by UnitOfWork commitAndResumeOnFailure to avoid corrupting the cache during a failed commit.
| |
| collectLocks | back to summary |
|---|---|
| public abstract void collectLocks(HashMap<K, V> threadList) Redeclares org. Add all locked CacheKeys to the map grouped by thread. Used to print all the locks in the identity map.
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object primaryKey) Implements org. Return true if an CacheKey with the primary key is in the map. User API. | |
| createCacheKey | back to summary |
|---|---|
| public CacheKey createCacheKey(Object primaryKey, Object object, Object writeLockValue, long readTime) Create the correct type of CacheKey for this map. | |
| elements | back to summary |
|---|---|
| public abstract Enumeration Redeclares org. Allow for the cache to be iterated on.
| |
| get | back to summary |
|---|---|
| public Object get(Object primaryKey) Implements org. Return the object cached in the identity map or null if it could not be found. User API.
| |
| getAllCacheKeysFromIdentityMapWithEntityPK | back to summary |
|---|---|
| public Map Implements org. ADVANCED: Using a list of Entity PK this method will attempt to bulk load the entire list from the cache. In certain circumstances this can have large performance improvements over loading each item individually. | |
| getAllFromIdentityMapWithEntityPK | back to summary |
|---|---|
| public Map Implements org. ADVANCED: Using a list of Entity PK this method will attempt to bulk load the entire list from the cache. In certain circumstances this can have large performance improvements over loading each item individually. | |
| getCacheKey | back to summary |
|---|---|
| public abstract CacheKey getCacheKey(Object primaryKey, boolean forMerge) Redeclares org. Get the cache key (with object) for the primary key.
| |
| getCacheKeyForLock | back to summary |
|---|---|
| public CacheKey getCacheKeyForLock(Object primaryKey) Implements org. Get the cache key (with object) for the primary key.
| |
| getCacheKeyWithReadLock | back to summary |
|---|---|
| protected CacheKey getCacheKeyWithReadLock(Object primaryKey) Get the cache key (with object) for the primary key with read lock. | |
| getDefaultIdentityMapClass | back to summary |
|---|---|
| public static Class Returns the class which should be used as an identity map in a descriptor by default. | |
| getDescriptor | back to summary |
|---|---|
| public ClassDescriptor getDescriptor() Implements org. Return the class that this is the map for.
| |
| getDescriptorClass | back to summary |
|---|---|
| public Class Implements org. Return the class that this is the map for.
| |
| getMaxSize | back to summary |
|---|---|
| public int getMaxSize() Implements org.
| |
| getSize | back to summary |
|---|---|
| public abstract int getSize() Redeclares org. Return the number of CacheKeys in the IdentityMap. This may contain weak referenced objects that have been garbage collected.
| |
| getSize | back to summary |
|---|---|
| public abstract int getSize(Class<?> myClass, boolean recurse) Redeclares org. Return the number of actual objects of type myClass in the IdentityMap. Recurse = true will include subclasses of myClass in the count.
| |
| getWrapper | back to summary |
|---|---|
| public Object getWrapper(Object primaryKey) Implements org. Get the wrapper object from the cache key associated with the given primary key, this is used for EJB2.
| |
| getWriteLockValue | back to summary |
|---|---|
| public Object getWriteLockValue(Object primaryKey) Implements org. Get the write lock value from the cache key associated to the primarykey. User API.
| |
| keys | back to summary |
|---|---|
| public abstract Enumeration Redeclares org. Allow for the CacheKeys to be iterated on.
| |
| put | back to summary |
|---|---|
| public abstract CacheKey put(Object primaryKey, Object object, Object writeLockValue, long readTime) Redeclares org. Store the object in the cache at its primary key. This is used by InsertObjectQuery, typically into the UnitOfWork identity map. Merge and reads do not use put, but acquireLock. Also an advanced (very) user API. | |
| putCacheKeyIfAbsent | back to summary |
|---|---|
| protected abstract CacheKey putCacheKeyIfAbsent(CacheKey cacheKey) Return the CacheKey (with object) matching the searchKey. If the CacheKey is missing then put the searchKey in the map. The searchKey should have already been locked. | |
| release | back to summary |
|---|---|
| public void release() Implements org. This method may be called during initialize all identity maps. It allows the identity map or interceptor the opportunity to release any resources before being thrown away.
| |
| remove | back to summary |
|---|---|
| public Object remove(Object primaryKey, Object object) Implements org. Remove the CacheKey with the primaryKey from the map. This is used by DeleteObjectQuery and merge. This is also an advanced (very) user API.
| |
| remove | back to summary |
|---|---|
| public abstract Object remove(CacheKey cacheKey) Redeclares org. Remove the CacheKey from the map.
| |
| setDescriptor | back to summary |
|---|---|
| public void setDescriptor(ClassDescriptor descriptor) Implements org. Set the descriptor that this is the map for.
| |
| setMaxSize | back to summary |
|---|---|
| protected synchronized void setMaxSize(int size) Set the maximum size for the receiver.
| |
| setWrapper | back to summary |
|---|---|
| public void setWrapper(Object primaryKey, Object wrapper) Implements org. Update the wrapper object in the CacheKey associated with the given primaryKey, this is used for EJB2.
| |
| setWriteLockValue | back to summary |
|---|---|
| public void setWriteLockValue(Object primaryKey, Object writeLockValue) Implements org. Update the write lock value of the CacheKey associated with the given primaryKey. This is used by UpdateObjectQuery, and is also an advanced (very) user API.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements org. Doc from java. Returns a string representation of the object. | |
| updateMaxSize | back to summary |
|---|---|
| public void updateMaxSize(int maxSize) Implements org. This method will be used to update the max cache size, any objects exceeding the max cache size will be remove from the cache. Please note that this does not remove the object from the identityMap, except in the case of the CacheIdentityMap.
| |