Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

E28847-01


oracle.eclipselink.coherence.integrated.cache
Class CoherenceInterceptor

java.lang.Object
  extended by org.eclipse.persistence.sessions.interceptors.CacheInterceptor
      extended by oracle.eclipselink.coherence.integrated.cache.CoherenceInterceptor

All Implemented Interfaces:
java.lang.Cloneable, org.eclipse.persistence.internal.identitymaps.IdentityMap

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

Since:
Oracle TopLink 11g (11.1.1.0.0)
Author:
gyorke
See Also:
org.eclipse.persistence.descriptors.ClassDescriptor.setCacheInterceptorClass, org.eclipse.persistence.annoations.CacheInterceptor

Nested Class Summary
 class CoherenceInterceptor.CoherenceOnlyCacheKeyWrapper
           

 

Field Summary
protected  ClassDescriptor descriptor
           
protected  org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy lockingPolicy
           
protected  com.tangosol.net.NamedCache namedCache
           
protected  boolean shouldTranslatePKs
           

 

Fields inherited from class org.eclipse.persistence.sessions.interceptors.CacheInterceptor
interceptedSession, targetIdentityMap

 

Constructor Summary
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.

 

Method Summary
 org.eclipse.persistence.internal.identitymaps.CacheKey acquireDeferredLock(java.lang.Object primaryKey)
          Acquire a deferred lock on the object.
 org.eclipse.persistence.internal.identitymaps.CacheKey acquireLock(java.lang.Object primaryKey, boolean forMerge)
          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.
 java.lang.Object clone()
          Clone the map and all of the CacheKeys.
protected  CacheKeyInterceptor createCacheKeyInterceptor(org.eclipse.persistence.internal.identitymaps.CacheKey wrappedCacheKey)
           
 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.
 void lazyRelationshipLoaded(java.lang.Object object, 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.

 

Methods inherited from class org.eclipse.persistence.sessions.interceptors.CacheInterceptor
acquireReadLockOnCacheKey, acquireReadLockOnCacheKeyNoWait, collectLocks, containsKey, elements, get, getDescriptor, getDescriptorClass, getMaxSize, getSize, getSize, getTargetIdenttyMap, getWrapper, getWriteLockValue, keys, keys, setDescriptor, setWrapper, setWriteLockValue, toString, updateMaxSize

 

Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

namedCache

protected com.tangosol.net.NamedCache namedCache

descriptor

protected ClassDescriptor descriptor

lockingPolicy

protected org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy lockingPolicy

shouldTranslatePKs

protected boolean shouldTranslatePKs

Constructor Detail

CoherenceInterceptor

public 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. This is an internal method as this class should not be instantiated by the user.

Method Detail

createCacheKeyInterceptor

protected CacheKeyInterceptor createCacheKeyInterceptor(org.eclipse.persistence.internal.identitymaps.CacheKey wrappedCacheKey)
Specified by:
createCacheKeyInterceptor in class CacheInterceptor

clone

public java.lang.Object clone()
Description copied from class: CacheInterceptor
Clone the map and all of the CacheKeys. This is used by UnitOfWork commitAndResumeOnFailure to avoid corrupting the cache during a failed commit.
Specified by:
clone in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Specified by:
clone in class CacheInterceptor

acquireDeferredLock

public org.eclipse.persistence.internal.identitymaps.CacheKey acquireDeferredLock(java.lang.Object primaryKey)
Acquire a deferred lock on the object. This is used while reading if the object has relationships without indirection. This first thread will get an active lock. Other threads will get deferred locks, all threads will wait until all other threads are complete before releasing their locks.
Specified by:
acquireDeferredLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
acquireDeferredLock in class CacheInterceptor

acquireLock

public org.eclipse.persistence.internal.identitymaps.CacheKey acquireLock(java.lang.Object primaryKey,
                                                                          boolean forMerge)
Acquire an active lock on the object. This is used by reading (when using indirection or no relationships) and by merge.
Specified by:
acquireLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
acquireLock in class CacheInterceptor

acquireLockNoWait

public org.eclipse.persistence.internal.identitymaps.CacheKey acquireLockNoWait(java.lang.Object primaryKey,
                                                                                boolean forMerge)
Acquire an active lock on the object, if not already locked. This is used by merge for missing existing objects.
Specified by:
acquireLockNoWait in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
acquireLockNoWait in class CacheInterceptor

acquireLockWithWait

public 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. This is used by merge for missing existing objects.
Specified by:
acquireLockWithWait in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
acquireLockWithWait in class CacheInterceptor

getAllFromIdentityMapWithEntityPK

public 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. In certain circumstances this can have large performance improvements over loading each item individually.
Specified by:
getAllFromIdentityMapWithEntityPK in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Specified by:
getAllFromIdentityMapWithEntityPK in class CacheInterceptor
Parameters:
pkList - List of Entity PKs to extract from the cache
ClassDescriptor - Descriptor type to be retrieved.
Returns:
Map of Entity PKs associated to the Entities that were retrieved
Throws:
QueryException

getCacheKey

public org.eclipse.persistence.internal.identitymaps.CacheKey getCacheKey(java.lang.Object searchKey,
                                                                          boolean forMerge)
Return the cache key (with object) matching the searchKey.
Specified by:
getCacheKey in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
getCacheKey in class CacheInterceptor

getCacheKeyForLock

public org.eclipse.persistence.internal.identitymaps.CacheKey getCacheKeyForLock(java.lang.Object searchKey)
Return the cache key (with object) matching the searchKey.
Specified by:
getCacheKeyForLock in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
getCacheKeyForLock in class CacheInterceptor

lazyRelationshipLoaded

public void lazyRelationshipLoaded(java.lang.Object object,
                                   ForeignReferenceMapping mapping)
Notify the cache that a lazy relationship has been triggered in the object and the cache may need to be updated
Specified by:
lazyRelationshipLoaded in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
lazyRelationshipLoaded in class CacheInterceptor

put

public 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. This is used by InsertObjectQuery, typically into the UnitOfWork identity map. Merge and reads do not use put, but acquireLock. Also an advanced (very) user API.
Specified by:
put in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
put in class CacheInterceptor
Parameters:
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.

release

public void release()
Used to release the reference to the named cache durring initialize all identity maps.

remove

public java.lang.Object remove(java.lang.Object primaryKey,
                               java.lang.Object object)
Remove the CacheKey with the primaryKey from the map. This is used by DeleteObjectQuery and merge. This is also an advanced (very) user API.
Specified by:
remove in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
remove in class CacheInterceptor

remove

public java.lang.Object remove(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey)
Remove the CacheKey from the map.
Specified by:
remove in interface org.eclipse.persistence.internal.identitymaps.IdentityMap
Overrides:
remove in class CacheInterceptor

Skip navigation links

Copyright © 1998, 2012, Oracle. All Rights Reserved.