public abstract class AbstractIdentityMap extends java.lang.Object implements IdentityMap, java.io.Serializable, java.lang.Cloneable
Purpose: Caches objects, and allows their retrieval by their primary key.
Responsibilities:
CacheKey
,
Serialized FormConstructor 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(java.lang.Object primaryKey,
boolean isCacheCheckComplete)
Acquire a deferred lock on the object.
|
CacheKey |
acquireLock(java.lang.Object primaryKey,
boolean forMerge,
boolean isCacheCheckComplete)
Acquire an active lock on the object.
|
CacheKey |
acquireLockNoWait(java.lang.Object primaryKey,
boolean forMerge)
Acquire an active lock on the object, if not already locked.
|
CacheKey |
acquireLockWithWait(java.lang.Object primaryKey,
boolean forMerge,
int wait)
Acquire an active lock on the object, if not already locked.
|
CacheKey |
acquireReadLockOnCacheKey(java.lang.Object primaryKey)
Acquire a read lock on the object.
|
CacheKey |
acquireReadLockOnCacheKeyNoWait(java.lang.Object primaryKey)
Acquire a read lock on the object, if not already locked.
|
java.lang.Object |
clone()
Clone the map and all of the CacheKeys.
|
abstract void |
collectLocks(java.util.HashMap threadList)
Add all locked CacheKeys to the map grouped by thread.
|
boolean |
containsKey(java.lang.Object primaryKey)
Return true if an CacheKey with the primary key is in the map.
|
CacheKey |
createCacheKey(java.lang.Object primaryKey,
java.lang.Object object,
java.lang.Object writeLockValue,
long readTime)
Create the correct type of CacheKey for this map.
|
abstract java.util.Enumeration |
elements()
Allow for the cache to be iterated on.
|
java.lang.Object |
get(java.lang.Object primaryKey)
Return the object cached in the identity map or null if it could not be found.
|
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.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.
|
abstract CacheKey |
getCacheKey(java.lang.Object primaryKey,
boolean forMerge)
Get the cache key (with object) for the primary key.
|
CacheKey |
getCacheKeyForLock(java.lang.Object primaryKey)
Get the cache key (with object) for the primary key.
|
static java.lang.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.
|
java.lang.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(java.lang.Class myClass,
boolean recurse)
Return the number of actual objects of type myClass in the IdentityMap.
|
java.lang.Object |
getWrapper(java.lang.Object primaryKey)
Get the wrapper object from the cache key associated with the given primary key,
this is used for EJB2.
|
java.lang.Object |
getWriteLockValue(java.lang.Object primaryKey)
Get the write lock value from the cache key associated to the primarykey.
|
abstract java.util.Enumeration |
keys()
Allow for the CacheKeys to be iterated on.
|
abstract CacheKey |
put(java.lang.Object primaryKey,
java.lang.Object object,
java.lang.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 java.lang.Object |
remove(CacheKey cacheKey)
Remove the CacheKey from the map.
|
java.lang.Object |
remove(java.lang.Object primaryKey,
java.lang.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(java.lang.Object primaryKey,
java.lang.Object wrapper)
Update the wrapper object in the CacheKey associated with the given primaryKey,
this is used for EJB2.
|
void |
setWriteLockValue(java.lang.Object primaryKey,
java.lang.Object writeLockValue)
Update the write lock value of the CacheKey associated with the given primaryKey.
|
java.lang.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, wait
keys, lazyRelationshipLoaded
public 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(java.lang.Object primaryKey, boolean isCacheCheckComplete)
acquireDeferredLock
in interface IdentityMap
public CacheKey acquireLock(java.lang.Object primaryKey, boolean forMerge, boolean isCacheCheckComplete)
acquireLock
in interface IdentityMap
public CacheKey acquireLockNoWait(java.lang.Object primaryKey, boolean forMerge)
acquireLockNoWait
in interface IdentityMap
public CacheKey acquireLockWithWait(java.lang.Object primaryKey, boolean forMerge, int wait)
acquireLockWithWait
in interface IdentityMap
public CacheKey acquireReadLockOnCacheKey(java.lang.Object primaryKey)
acquireReadLockOnCacheKey
in interface IdentityMap
public CacheKey acquireReadLockOnCacheKeyNoWait(java.lang.Object primaryKey)
acquireReadLockOnCacheKeyNoWait
in interface IdentityMap
public abstract void collectLocks(java.util.HashMap threadList)
collectLocks
in interface IdentityMap
public java.lang.Object clone()
clone
in interface IdentityMap
clone
in class java.lang.Object
public boolean containsKey(java.lang.Object primaryKey)
containsKey
in interface IdentityMap
primaryKey
- is the primary key for the object to search for.public CacheKey createCacheKey(java.lang.Object primaryKey, java.lang.Object object, java.lang.Object writeLockValue, long readTime)
public abstract java.util.Enumeration elements()
elements
in interface IdentityMap
public java.lang.Object get(java.lang.Object primaryKey)
get
in interface IdentityMap
public java.util.Map<java.lang.Object,java.lang.Object> getAllFromIdentityMapWithEntityPK(java.lang.Object[] pkList, ClassDescriptor descriptor, AbstractSession session)
getAllFromIdentityMapWithEntityPK
in interface IdentityMap
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)
getAllCacheKeysFromIdentityMapWithEntityPK
in interface IdentityMap
pkList
- List of Entity PKs to extract from the cacheClassDescriptor
- Descriptor type to be retrieved.QueryException
public abstract CacheKey getCacheKey(java.lang.Object primaryKey, boolean forMerge)
getCacheKey
in interface IdentityMap
public CacheKey getCacheKeyForLock(java.lang.Object primaryKey)
getCacheKeyForLock
in interface IdentityMap
public static java.lang.Class getDefaultIdentityMapClass()
public int getMaxSize()
getMaxSize
in interface IdentityMap
public abstract int getSize()
getSize
in interface IdentityMap
public abstract int getSize(java.lang.Class myClass, boolean recurse)
getSize
in interface IdentityMap
public java.lang.Object getWrapper(java.lang.Object primaryKey)
getWrapper
in interface IdentityMap
public java.lang.Object getWriteLockValue(java.lang.Object primaryKey)
getWriteLockValue
in interface IdentityMap
public abstract java.util.Enumeration keys()
keys
in interface IdentityMap
public abstract CacheKey put(java.lang.Object primaryKey, java.lang.Object object, java.lang.Object writeLockValue, long readTime)
put
in interface IdentityMap
primaryKey
- 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 IdentityMap
public java.lang.Object remove(java.lang.Object primaryKey, java.lang.Object object)
remove
in interface IdentityMap
public abstract java.lang.Object remove(CacheKey cacheKey)
remove
in interface IdentityMap
public void updateMaxSize(int maxSize)
updateMaxSize
in interface IdentityMap
public ClassDescriptor getDescriptor()
getDescriptor
in interface IdentityMap
public java.lang.Class getDescriptorClass()
getDescriptorClass
in interface IdentityMap
public void setDescriptor(ClassDescriptor descriptor)
setDescriptor
in interface IdentityMap
public void setWrapper(java.lang.Object primaryKey, java.lang.Object wrapper)
setWrapper
in interface IdentityMap
public void setWriteLockValue(java.lang.Object primaryKey, java.lang.Object writeLockValue)
setWriteLockValue
in interface IdentityMap
public java.lang.String toString()
toString
in interface IdentityMap
toString
in class java.lang.Object
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference