public abstract class AbstractIdentityMap extends Object implements IdentityMap, Serializable, Cloneable
Purpose: Caches objects, and allows their retrieval by their primary key.
Responsibilities:
CacheKey,
Serialized Form| Constructor and Description |
|---|
AbstractIdentityMap() |
AbstractIdentityMap(int size,
ClassDescriptor descriptor,
AbstractSession session,
boolean isolated)
Instantiate an new IdentityMap with it's maximum size.
|
| Modifier and Type | Method and Description |
|---|---|
CacheKey |
acquireDeferredLock(Object primaryKey,
boolean isCacheCheckComplete)
Acquire a deferred lock on the object.
|
CacheKey |
acquireLock(Object primaryKey,
boolean forMerge,
boolean isCacheCheckComplete)
Acquire an active lock on the object.
|
CacheKey |
acquireLockNoWait(Object primaryKey,
boolean forMerge)
Acquire an active lock on the object, if not already locked.
|
CacheKey |
acquireLockWithWait(Object primaryKey,
boolean forMerge,
int wait)
Acquire an active lock on the object, if not already locked.
|
CacheKey |
acquireReadLockOnCacheKey(Object primaryKey)
Acquire a read lock on the object.
|
CacheKey |
acquireReadLockOnCacheKeyNoWait(Object primaryKey)
Acquire a read lock on the object, if not already locked.
|
Object |
clone()
Clone the map and all of the CacheKeys.
|
abstract void |
collectLocks(HashMap threadList)
Add all locked CacheKeys to the map grouped by thread.
|
boolean |
containsKey(Object primaryKey)
Return true if an CacheKey with the primary key is in the map.
|
CacheKey |
createCacheKey(Object primaryKey,
Object object,
Object writeLockValue,
long readTime)
Create the correct type of CacheKey for this map.
|
abstract Enumeration |
elements()
Allow for the cache to be iterated on.
|
Object |
get(Object primaryKey)
Return the object cached in the identity map or null if it could not be found.
|
Map<Object,CacheKey> |
getAllCacheKeysFromIdentityMapWithEntityPK(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.
|
Map<Object,Object> |
getAllFromIdentityMapWithEntityPK(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.
|
abstract CacheKey |
getCacheKey(Object primaryKey,
boolean forMerge)
Get the cache key (with object) for the primary key.
|
CacheKey |
getCacheKeyForLock(Object primaryKey)
Get the cache key (with object) for the primary key.
|
static Class |
getDefaultIdentityMapClass()
Returns the class which should be used as an identity map in a descriptor by default.
|
ClassDescriptor |
getDescriptor()
Return the class that this is the map for.
|
Class |
getDescriptorClass()
Return the class that this is the map for.
|
int |
getMaxSize() |
abstract int |
getSize()
Return the number of CacheKeys in the IdentityMap.
|
abstract int |
getSize(Class myClass,
boolean recurse)
Return the number of actual objects of type myClass in the IdentityMap.
|
Object |
getWrapper(Object primaryKey)
Get the wrapper object from the cache key associated with the given primary key,
this is used for EJB2.
|
Object |
getWriteLockValue(Object primaryKey)
Get the write lock value from the cache key associated to the primarykey.
|
abstract Enumeration |
keys()
Allow for the CacheKeys to be iterated on.
|
abstract CacheKey |
put(Object primaryKey,
Object object,
Object writeLockValue,
long readTime)
Store the object in the cache at its primary key.
|
void |
release()
This method may be called during initialize all identity maps.
|
abstract Object |
remove(CacheKey cacheKey)
Remove the CacheKey from the map.
|
Object |
remove(Object primaryKey,
Object object)
Remove the CacheKey with the primaryKey from the map.
|
void |
setDescriptor(ClassDescriptor descriptor)
Set the descriptor that this is the map for.
|
void |
setWrapper(Object primaryKey,
Object wrapper)
Update the wrapper object in the CacheKey associated with the given primaryKey,
this is used for EJB2.
|
void |
setWriteLockValue(Object primaryKey,
Object writeLockValue)
Update the write lock value of the CacheKey associated with the given primaryKey.
|
String |
toString() |
void |
updateMaxSize(int maxSize)
This method will be used to update the max cache size, any objects exceeding the max cache size will
be remove from the cache.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitkeys, lazyRelationshipLoadedpublic AbstractIdentityMap()
public AbstractIdentityMap(int size,
ClassDescriptor descriptor,
AbstractSession session,
boolean isolated)
NOTE: Subclasses may provide different behavior for maxSize.
size - is the maximum size to be allocated for the receiver.public CacheKey acquireDeferredLock(Object primaryKey, boolean isCacheCheckComplete)
acquireDeferredLock in interface IdentityMappublic CacheKey acquireLock(Object primaryKey, boolean forMerge, boolean isCacheCheckComplete)
acquireLock in interface IdentityMappublic CacheKey acquireLockNoWait(Object primaryKey, boolean forMerge)
acquireLockNoWait in interface IdentityMappublic CacheKey acquireLockWithWait(Object primaryKey, boolean forMerge, int wait)
acquireLockWithWait in interface IdentityMappublic CacheKey acquireReadLockOnCacheKey(Object primaryKey)
acquireReadLockOnCacheKey in interface IdentityMappublic CacheKey acquireReadLockOnCacheKeyNoWait(Object primaryKey)
acquireReadLockOnCacheKeyNoWait in interface IdentityMappublic abstract void collectLocks(HashMap threadList)
collectLocks in interface IdentityMappublic Object clone()
clone in interface IdentityMapclone in class Objectpublic boolean containsKey(Object primaryKey)
containsKey in interface IdentityMapprimaryKey - is the primary key for the object to search for.public CacheKey createCacheKey(Object primaryKey, Object object, Object writeLockValue, long readTime)
public abstract Enumeration elements()
elements in interface IdentityMappublic Object get(Object primaryKey)
get in interface IdentityMappublic Map<Object,Object> getAllFromIdentityMapWithEntityPK(Object[] pkList, ClassDescriptor descriptor, AbstractSession session)
getAllFromIdentityMapWithEntityPK in interface IdentityMappkList - List of Entity PKs to extract from the cacheClassDescriptor - Descriptor type to be retrieved.QueryExceptionpublic Map<Object,CacheKey> getAllCacheKeysFromIdentityMapWithEntityPK(Object[] pkList, ClassDescriptor descriptor, AbstractSession session)
getAllCacheKeysFromIdentityMapWithEntityPK in interface IdentityMappkList - List of Entity PKs to extract from the cacheClassDescriptor - Descriptor type to be retrieved.QueryExceptionpublic abstract CacheKey getCacheKey(Object primaryKey, boolean forMerge)
getCacheKey in interface IdentityMappublic CacheKey getCacheKeyForLock(Object primaryKey)
getCacheKeyForLock in interface IdentityMappublic static Class getDefaultIdentityMapClass()
public int getMaxSize()
getMaxSize in interface IdentityMappublic abstract int getSize()
getSize in interface IdentityMappublic abstract int getSize(Class myClass, boolean recurse)
getSize in interface IdentityMappublic Object getWrapper(Object primaryKey)
getWrapper in interface IdentityMappublic Object getWriteLockValue(Object primaryKey)
getWriteLockValue in interface IdentityMappublic abstract Enumeration keys()
keys in interface IdentityMappublic abstract CacheKey put(Object primaryKey, Object object, Object writeLockValue, long readTime)
put in interface IdentityMapprimaryKey - is the primary key for the object.object - is the domain object to cache.writeLockValue - is the current write lock value of object, if null the version is ignored.public void release()
release in interface IdentityMappublic Object remove(Object primaryKey, Object object)
remove in interface IdentityMappublic abstract Object remove(CacheKey cacheKey)
remove in interface IdentityMappublic void updateMaxSize(int maxSize)
updateMaxSize in interface IdentityMappublic ClassDescriptor getDescriptor()
getDescriptor in interface IdentityMappublic Class getDescriptorClass()
getDescriptorClass in interface IdentityMappublic void setDescriptor(ClassDescriptor descriptor)
setDescriptor in interface IdentityMappublic void setWrapper(Object primaryKey, Object wrapper)
setWrapper in interface IdentityMappublic void setWriteLockValue(Object primaryKey, Object writeLockValue)
setWriteLockValue in interface IdentityMappublic String toString()
toString in interface IdentityMaptoString in class ObjectEclipseLink 2.6.3, "build v20160428-59c81c5" API Reference