public abstract class CacheInterceptor extends Object implements org.eclipse.persistence.internal.identitymaps.IdentityMap
Purpose: Define a class through which Cache access can be intercepted.
Description: EclipseLink makes extensive use of caching functionality. This class provides the mechanism for intercepting the cache access. Once intercepted applications can allow the process to continue by calling the method on the class attribute targetIdentityMap as described in the API javadocs or redirect the process entirely. * As with IdentityMaps an entire class inheritance hierarchy will share the same interceptor.
To implement a CacheInterceptor users should subclass this class implementing those methods they wish to intercept.
Configuration: Interceptors may be added to a session by using a Session or Descriptor customizer to set the class name of the interceptor on the target ClassDescriptor through the method setCacheInterceptorClass(Class).
| Modifier and Type | Field and Description |
|---|---|
protected org.eclipse.persistence.internal.sessions.AbstractSession |
interceptedSession |
protected org.eclipse.persistence.internal.identitymaps.IdentityMap |
targetIdentityMap
This attribute stores the actual IdentityMap as configured by the user.
|
| Constructor and Description |
|---|
CacheInterceptor(org.eclipse.persistence.internal.identitymaps.IdentityMap targetIdentityMap,
org.eclipse.persistence.internal.sessions.AbstractSession interceptedSession) |
| Modifier and Type | Method and Description |
|---|---|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireDeferredLock(Object primaryKey,
boolean isCacheCheckComplete)
Acquire a deferred lock on the object.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireLock(Object primaryKey,
boolean forMerge,
boolean isCacheCheckComplete)
Acquire an active lock on the object.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireLockNoWait(Object primaryKey,
boolean forMerge)
Acquire an active lock on the object, if not already locked.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireLockWithWait(Object primaryKey,
boolean forMerge,
int wait)
Acquire an active lock on the object, if not already locked.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireReadLockOnCacheKey(Object primaryKey)
Acquire a read lock on the object.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireReadLockOnCacheKeyNoWait(Object primaryKey)
Acquire a read lock on the object, if not already locked.
|
abstract Object |
clone()
Clone the map and all of the CacheKeys.
|
Enumeration<org.eclipse.persistence.internal.identitymaps.CacheKey> |
cloneKeys()
Allow for the
CacheKey elements to be iterated. |
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.
|
protected abstract CacheKeyInterceptor |
createCacheKeyInterceptor(org.eclipse.persistence.internal.identitymaps.CacheKey wrappedCacheKey) |
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.
|
abstract Map<Object,org.eclipse.persistence.internal.identitymaps.CacheKey> |
getAllCacheKeysFromIdentityMapWithEntityPK(Object[] pkList,
ClassDescriptor descriptor,
org.eclipse.persistence.internal.sessions.AbstractSession session)
ADVANCED:
Using a list of Entity PK this method will attempt to bulk load the entire list from the cache.
|
abstract Map<Object,Object> |
getAllFromIdentityMapWithEntityPK(Object[] pkList,
ClassDescriptor descriptor,
org.eclipse.persistence.internal.sessions.AbstractSession session)
ADVANCED:
Using a list of Entity PK this method will attempt to bulk load the entire list from the cache.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
getCacheKey(Object primaryKey,
boolean forMerge)
Get the cache key (with object) for the primary key.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
getCacheKeyForLock(Object primaryKey)
Get the cache key (with object) for the primary key.
|
ClassDescriptor |
getDescriptor()
Return the descriptor that this is the map for.
|
Class |
getDescriptorClass()
Return the class that this is the map for.
|
int |
getMaxSize() |
int |
getSize()
Return the number of CacheKeys in the IdentityMap.
|
int |
getSize(Class myClass,
boolean recurse)
Return the number of actual objects of type myClass in the IdentityMap.
|
org.eclipse.persistence.internal.identitymaps.IdentityMap |
getTargetIdenttyMap()
Return the instance of the IdentityMap that this intercpetor is wrapping.
|
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.
|
Enumeration<org.eclipse.persistence.internal.identitymaps.CacheKey> |
keys()
Allow for the
CacheKey elements to be iterated. |
Enumeration<org.eclipse.persistence.internal.identitymaps.CacheKey> |
keys(boolean checkReadLocks)
Allow for the
CacheKey elements to be iterated. |
void |
lazyRelationshipLoaded(Object rootEntity,
ValueHolderInterface valueHolder,
ForeignReferenceMapping mapping)
Notify the cache that a lazy relationship has been triggered in the object
and the cache may need to be updated
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
put(Object primaryKey,
Object object,
Object writeLockValue,
long readTime)
Store the object in the cache at its primary key.
|
Object |
remove(org.eclipse.persistence.internal.identitymaps.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.
|
protected org.eclipse.persistence.internal.identitymaps.IdentityMap targetIdentityMap
protected org.eclipse.persistence.internal.sessions.AbstractSession interceptedSession
public CacheInterceptor(org.eclipse.persistence.internal.identitymaps.IdentityMap targetIdentityMap,
org.eclipse.persistence.internal.sessions.AbstractSession interceptedSession)
public org.eclipse.persistence.internal.identitymaps.CacheKey acquireDeferredLock(Object primaryKey, boolean isCacheCheckComplete)
acquireDeferredLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic org.eclipse.persistence.internal.identitymaps.CacheKey acquireLock(Object primaryKey, boolean forMerge, boolean isCacheCheckComplete)
acquireLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic org.eclipse.persistence.internal.identitymaps.CacheKey acquireLockNoWait(Object primaryKey, boolean forMerge)
acquireLockNoWait in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic org.eclipse.persistence.internal.identitymaps.CacheKey acquireLockWithWait(Object primaryKey, boolean forMerge, int wait)
acquireLockWithWait in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic org.eclipse.persistence.internal.identitymaps.CacheKey acquireReadLockOnCacheKey(Object primaryKey)
acquireReadLockOnCacheKey in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic org.eclipse.persistence.internal.identitymaps.CacheKey acquireReadLockOnCacheKeyNoWait(Object primaryKey)
acquireReadLockOnCacheKeyNoWait in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic void collectLocks(HashMap threadList)
collectLocks in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic abstract Object clone()
public boolean containsKey(Object primaryKey)
containsKey in interface org.eclipse.persistence.internal.identitymaps.IdentityMapprimaryKey - is the primary key for the object to search for.protected abstract CacheKeyInterceptor createCacheKeyInterceptor(org.eclipse.persistence.internal.identitymaps.CacheKey wrappedCacheKey)
public Enumeration elements()
elements in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic Object get(Object primaryKey)
get in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic abstract Map<Object,Object> getAllFromIdentityMapWithEntityPK(Object[] pkList, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)
getAllFromIdentityMapWithEntityPK in interface org.eclipse.persistence.internal.identitymaps.IdentityMappkList - List of Entity PKs to extract from the cachedescriptor - Descriptor type to be retrieved.QueryExceptionpublic abstract Map<Object,org.eclipse.persistence.internal.identitymaps.CacheKey> getAllCacheKeysFromIdentityMapWithEntityPK(Object[] pkList, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)
getAllCacheKeysFromIdentityMapWithEntityPK in interface org.eclipse.persistence.internal.identitymaps.IdentityMappkList - List of Entity PKs to extract from the cachedescriptor - Descriptor type to be retrieved.QueryExceptionpublic org.eclipse.persistence.internal.identitymaps.CacheKey getCacheKey(Object primaryKey, boolean forMerge)
getCacheKey in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic org.eclipse.persistence.internal.identitymaps.CacheKey getCacheKeyForLock(Object primaryKey)
getCacheKeyForLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic ClassDescriptor getDescriptor()
getDescriptor in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic Class getDescriptorClass()
getDescriptorClass in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic int getMaxSize()
getMaxSize in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic int getSize()
getSize in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic int getSize(Class myClass, boolean recurse)
getSize in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic org.eclipse.persistence.internal.identitymaps.IdentityMap getTargetIdenttyMap()
public Object getWrapper(Object primaryKey)
getWrapper in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic Object getWriteLockValue(Object primaryKey)
getWriteLockValue in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic Enumeration<org.eclipse.persistence.internal.identitymaps.CacheKey> keys()
CacheKey elements to be iterated.
CacheKey Collection is reused so this iteration may not be thread safe.keys in interface org.eclipse.persistence.internal.identitymaps.IdentityMapEnumeration of CacheKey instances.public Enumeration<org.eclipse.persistence.internal.identitymaps.CacheKey> cloneKeys()
CacheKey elements to be iterated.
Clone of CacheKey Collection is returned so this iteration should
be thread safe.cloneKeys in interface org.eclipse.persistence.internal.identitymaps.IdentityMapEnumeration with clone of the CacheKey Collectionpublic Enumeration<org.eclipse.persistence.internal.identitymaps.CacheKey> keys(boolean checkReadLocks)
CacheKey elements to be iterated.
CacheKey Collection is reused so this iteration may not be thread safe.keys in interface org.eclipse.persistence.internal.identitymaps.IdentityMapcheckReadLocks - value of true if read lock on the CacheKey
instances should be checked or false otherwiseEnumeration of CacheKey instances.public void lazyRelationshipLoaded(Object rootEntity, ValueHolderInterface valueHolder, ForeignReferenceMapping mapping)
lazyRelationshipLoaded in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic org.eclipse.persistence.internal.identitymaps.CacheKey put(Object primaryKey, Object object, Object writeLockValue, long readTime)
put in interface org.eclipse.persistence.internal.identitymaps.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 Object remove(Object primaryKey, Object object)
remove in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic Object remove(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey)
remove in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic void updateMaxSize(int maxSize)
updateMaxSize in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic void setDescriptor(ClassDescriptor descriptor)
setDescriptor in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic void setWrapper(Object primaryKey, Object wrapper)
setWrapper in interface org.eclipse.persistence.internal.identitymaps.IdentityMappublic void setWriteLockValue(Object primaryKey, Object writeLockValue)
setWriteLockValue in interface org.eclipse.persistence.internal.identitymaps.IdentityMapCopyright © 2007–2021 Eclipse.org - EclipseLink Project. All rights reserved.