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()
CacheInterceptor
clone
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
clone
in class CacheInterceptor
public 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.IdentityMap
acquireDeferredLock
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.IdentityMap
acquireLock
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.IdentityMap
acquireLockNoWait
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.IdentityMap
acquireLockWithWait
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.IdentityMap
getAllFromIdentityMapWithEntityPK
in class CacheInterceptor
pkList
- 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.IdentityMap
getAllCacheKeysFromIdentityMapWithEntityPK
in class CacheInterceptor
pkList
- 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.IdentityMap
getCacheKey
in class CacheInterceptor
public org.eclipse.persistence.internal.identitymaps.CacheKey getCacheKeyForLock(java.lang.Object searchKey)
getCacheKeyForLock
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
getCacheKeyForLock
in class CacheInterceptor
public com.tangosol.net.NamedCache getNamedCache()
public void lazyRelationshipLoaded(java.lang.Object rootEntity, ValueHolderInterface valueHolder, ForeignReferenceMapping mapping)
lazyRelationshipLoaded
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
lazyRelationshipLoaded
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.IdentityMap
put
in class CacheInterceptor
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()
public java.lang.Object remove(java.lang.Object primaryKey, java.lang.Object object)
remove
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
remove
in class CacheInterceptor
public java.lang.Object remove(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey)
remove
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
remove
in class CacheInterceptor
public org.eclipse.persistence.internal.identitymaps.CacheKey acquireReadLockOnCacheKey(java.lang.Object primaryKey)
CacheInterceptor
acquireReadLockOnCacheKey
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
acquireReadLockOnCacheKey
in class CacheInterceptor
public org.eclipse.persistence.internal.identitymaps.CacheKey acquireReadLockOnCacheKeyNoWait(java.lang.Object primaryKey)
CacheInterceptor
acquireReadLockOnCacheKeyNoWait
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
acquireReadLockOnCacheKeyNoWait
in class CacheInterceptor
public boolean containsKey(java.lang.Object primaryKey)
CacheInterceptor
containsKey
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
containsKey
in class CacheInterceptor
primaryKey
- is the primary key for the object to search for.public java.util.Enumeration elements()
CacheInterceptor
elements
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
elements
in class CacheInterceptor
public java.lang.Object get(java.lang.Object primaryKey)
CacheInterceptor
get
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
get
in class CacheInterceptor
public int getMaxSize()
getMaxSize
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
getMaxSize
in class CacheInterceptor
public int getSize()
CacheInterceptor
getSize
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
getSize
in class CacheInterceptor
public int getSize(java.lang.Class myClass, boolean recurse)
CacheInterceptor
getSize
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
getSize
in class CacheInterceptor
public java.lang.Object getWrapper(java.lang.Object primaryKey)
CacheInterceptor
getWrapper
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
getWrapper
in class CacheInterceptor
public java.lang.Object getWriteLockValue(java.lang.Object primaryKey)
CacheInterceptor
getWriteLockValue
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
getWriteLockValue
in class CacheInterceptor
public void updateMaxSize(int maxSize)
CacheInterceptor
updateMaxSize
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
updateMaxSize
in class CacheInterceptor
public void setDescriptor(ClassDescriptor descriptor)
CacheInterceptor
setDescriptor
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
setDescriptor
in class CacheInterceptor
public void setWrapper(java.lang.Object primaryKey, java.lang.Object wrapper)
CacheInterceptor
setWrapper
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
setWrapper
in class CacheInterceptor
public void setWriteLockValue(java.lang.Object primaryKey, java.lang.Object writeLockValue)
CacheInterceptor
setWriteLockValue
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
setWriteLockValue
in class CacheInterceptor
public java.lang.String toString()
toString
in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
toString
in class CacheInterceptor
public boolean shouldTriggerFetchGroups()
public void setTriggerFetchGroups(boolean triggerFetchGroups)