public class CoherenceInterceptor extends CacheInterceptor
Purpose: This Cache Interceptor should be set on the descriptor for any class that is cached within Coherence. Once this Interceptor is applied EclipseLink will ensure that all Entities read into EclipseLink or updated by EclipseLink will be put into the Coherence Cache. TopLink cache settings will not be used. Developers should set the Coherence Cache name that corresponds to this class in a descriptor property called "coherence.cache.name". Each class should have its own Cache unless the PK's of the instances are unique amoung all classes stored in a single cache This Interceptor can be set on the class descriptor through a Session or Descriptor customizer or annotations
org.eclipse.persistence.descriptors.ClassDescriptor.setCacheInterceptorClass, org.eclipse.persistence.annoations.CacheInterceptor| Modifier and Type | Class and Description |
|---|---|
class |
CoherenceInterceptor.CoherenceOnlyCacheKeyWrapper |
| Constructor and Description |
|---|
CoherenceInterceptor(org.eclipse.persistence.internal.identitymaps.IdentityMap targetIdentityMap, org.eclipse.persistence.internal.sessions.AbstractSession interceptedSession)
Instantiate an new Cache Interceptor passing in the identity map that will be intercepted and the session that holds that identity map.
|
| Modifier and Type | Method and Description |
|---|---|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireDeferredLock(java.lang.Object primaryKey, boolean isCacheCheckComplete)
Acquire a deferred lock on the object.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireLock(java.lang.Object primaryKey, boolean forMerge, boolean isCacheCheckComplete)
Acquire an active lock on the object.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireLockNoWait(java.lang.Object primaryKey, boolean forMerge)
Acquire an active lock on the object, if not already locked.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireLockWithWait(java.lang.Object primaryKey, boolean forMerge, int wait)
Acquire an active lock on the object, if not already locked.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
acquireReadLockOnCacheKey(java.lang.Object primaryKey)
Acquire a read lock on the object.
|
org.eclipse.persistence.internal.identitymaps.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.
|
boolean |
containsKey(java.lang.Object primaryKey)
Return true if an CacheKey with the primary key is in the map.
|
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,org.eclipse.persistence.internal.identitymaps.CacheKey> |
getAllCacheKeysFromIdentityMapWithEntityPK(java.lang.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.
|
java.util.Map<java.lang.Object,java.lang.Object> |
getAllFromIdentityMapWithEntityPK(java.lang.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(java.lang.Object searchKey, boolean forMerge)
Return the cache key (with object) matching the searchKey.
|
org.eclipse.persistence.internal.identitymaps.CacheKey |
getCacheKeyForLock(java.lang.Object searchKey)
Return the cache key (with object) matching the searchKey.
|
int |
getMaxSize() |
com.tangosol.net.NamedCache |
getNamedCache() |
int |
getSize()
Return the number of CacheKeys in the IdentityMap.
|
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.
|
void |
lazyRelationshipLoaded(java.lang.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(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()
Used to release the reference to the named cache durring initialize all identity maps.
|
java.lang.Object |
remove(org.eclipse.persistence.internal.identitymaps.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 |
setTriggerFetchGroups(boolean triggerFetchGroups) |
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.
|
boolean |
shouldTriggerFetchGroups() |
java.lang.String |
toString() |
void |
trackComponents(ClassDescriptor sourceDesc, ClassDescriptor root, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean allowSharedComponents) |
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.
|
collectLocks, getDescriptor, getDescriptorClass, getTargetIdenttyMap, keys, keys
public CoherenceInterceptor(org.eclipse.persistence.internal.identitymaps.IdentityMap targetIdentityMap,
org.eclipse.persistence.internal.sessions.AbstractSession interceptedSession)
public java.lang.Object clone()
CacheInterceptorclone in interface org.eclipse.persistence.internal.identitymaps.IdentityMapclone in class CacheInterceptorpublic void trackComponents(ClassDescriptor sourceDesc, ClassDescriptor root, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean allowSharedComponents)
public org.eclipse.persistence.internal.identitymaps.CacheKey acquireDeferredLock(java.lang.Object primaryKey,
boolean isCacheCheckComplete)
acquireDeferredLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMapacquireDeferredLock in class CacheInterceptor
public org.eclipse.persistence.internal.identitymaps.CacheKey acquireLock(java.lang.Object primaryKey,
boolean forMerge,
boolean isCacheCheckComplete)
acquireLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMapacquireLock in class CacheInterceptor
public org.eclipse.persistence.internal.identitymaps.CacheKey acquireLockNoWait(java.lang.Object primaryKey,
boolean forMerge)
acquireLockNoWait in interface org.eclipse.persistence.internal.identitymaps.IdentityMapacquireLockNoWait in class CacheInterceptor
public org.eclipse.persistence.internal.identitymaps.CacheKey acquireLockWithWait(java.lang.Object primaryKey,
boolean forMerge,
int wait)
acquireLockWithWait in interface org.eclipse.persistence.internal.identitymaps.IdentityMapacquireLockWithWait in class CacheInterceptor
public java.util.Map<java.lang.Object,java.lang.Object> getAllFromIdentityMapWithEntityPK(java.lang.Object[] pkList,
ClassDescriptor descriptor,
org.eclipse.persistence.internal.sessions.AbstractSession session)
getAllFromIdentityMapWithEntityPK in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetAllFromIdentityMapWithEntityPK in class CacheInterceptorpkList - List of Entity PKs to extract from the cacheClassDescriptor - Descriptor type to be retrieved.QueryException
public java.util.Map<java.lang.Object,org.eclipse.persistence.internal.identitymaps.CacheKey> getAllCacheKeysFromIdentityMapWithEntityPK(java.lang.Object[] pkList,
ClassDescriptor descriptor,
org.eclipse.persistence.internal.sessions.AbstractSession session)
getAllCacheKeysFromIdentityMapWithEntityPK in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetAllCacheKeysFromIdentityMapWithEntityPK in class CacheInterceptorpkList - List of Entity PKs to extract from the cacheClassDescriptor - Descriptor type to be retrieved.QueryException
public org.eclipse.persistence.internal.identitymaps.CacheKey getCacheKey(java.lang.Object searchKey,
boolean forMerge)
getCacheKey in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetCacheKey in class CacheInterceptorpublic org.eclipse.persistence.internal.identitymaps.CacheKey getCacheKeyForLock(java.lang.Object searchKey)
getCacheKeyForLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetCacheKeyForLock in class CacheInterceptorpublic com.tangosol.net.NamedCache getNamedCache()
public void lazyRelationshipLoaded(java.lang.Object rootEntity,
ValueHolderInterface valueHolder,
ForeignReferenceMapping mapping)
lazyRelationshipLoaded in interface org.eclipse.persistence.internal.identitymaps.IdentityMaplazyRelationshipLoaded in class CacheInterceptor
public org.eclipse.persistence.internal.identitymaps.CacheKey put(java.lang.Object primaryKey,
java.lang.Object object,
java.lang.Object writeLockValue,
long readTime)
put in interface org.eclipse.persistence.internal.identitymaps.IdentityMapput in class CacheInterceptorprimaryKey - 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()
public java.lang.Object remove(java.lang.Object primaryKey,
java.lang.Object object)
remove in interface org.eclipse.persistence.internal.identitymaps.IdentityMapremove in class CacheInterceptorpublic java.lang.Object remove(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey)
remove in interface org.eclipse.persistence.internal.identitymaps.IdentityMapremove in class CacheInterceptorpublic org.eclipse.persistence.internal.identitymaps.CacheKey acquireReadLockOnCacheKey(java.lang.Object primaryKey)
CacheInterceptoracquireReadLockOnCacheKey in interface org.eclipse.persistence.internal.identitymaps.IdentityMapacquireReadLockOnCacheKey in class CacheInterceptorpublic org.eclipse.persistence.internal.identitymaps.CacheKey acquireReadLockOnCacheKeyNoWait(java.lang.Object primaryKey)
CacheInterceptoracquireReadLockOnCacheKeyNoWait in interface org.eclipse.persistence.internal.identitymaps.IdentityMapacquireReadLockOnCacheKeyNoWait in class CacheInterceptorpublic boolean containsKey(java.lang.Object primaryKey)
CacheInterceptorcontainsKey in interface org.eclipse.persistence.internal.identitymaps.IdentityMapcontainsKey in class CacheInterceptorprimaryKey - is the primary key for the object to search for.public java.util.Enumeration elements()
CacheInterceptorelements in interface org.eclipse.persistence.internal.identitymaps.IdentityMapelements in class CacheInterceptorpublic java.lang.Object get(java.lang.Object primaryKey)
CacheInterceptorget in interface org.eclipse.persistence.internal.identitymaps.IdentityMapget in class CacheInterceptorpublic int getMaxSize()
getMaxSize in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetMaxSize in class CacheInterceptorpublic int getSize()
CacheInterceptorgetSize in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetSize in class CacheInterceptor
public int getSize(java.lang.Class myClass,
boolean recurse)
CacheInterceptorgetSize in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetSize in class CacheInterceptorpublic java.lang.Object getWrapper(java.lang.Object primaryKey)
CacheInterceptorgetWrapper in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetWrapper in class CacheInterceptorpublic java.lang.Object getWriteLockValue(java.lang.Object primaryKey)
CacheInterceptorgetWriteLockValue in interface org.eclipse.persistence.internal.identitymaps.IdentityMapgetWriteLockValue in class CacheInterceptorpublic void updateMaxSize(int maxSize)
CacheInterceptorupdateMaxSize in interface org.eclipse.persistence.internal.identitymaps.IdentityMapupdateMaxSize in class CacheInterceptorpublic void setDescriptor(ClassDescriptor descriptor)
CacheInterceptorsetDescriptor in interface org.eclipse.persistence.internal.identitymaps.IdentityMapsetDescriptor in class CacheInterceptor
public void setWrapper(java.lang.Object primaryKey,
java.lang.Object wrapper)
CacheInterceptorsetWrapper in interface org.eclipse.persistence.internal.identitymaps.IdentityMapsetWrapper in class CacheInterceptor
public void setWriteLockValue(java.lang.Object primaryKey,
java.lang.Object writeLockValue)
CacheInterceptorsetWriteLockValue in interface org.eclipse.persistence.internal.identitymaps.IdentityMapsetWriteLockValue in class CacheInterceptorpublic java.lang.String toString()
toString in interface org.eclipse.persistence.internal.identitymaps.IdentityMaptoString in class CacheInterceptorpublic boolean shouldTriggerFetchGroups()
public void setTriggerFetchGroups(boolean triggerFetchGroups)