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 AbstractSession | |
| protected IdentityMap | targetIdentityMap
This attribute stores the actual IdentityMap as configured by the user. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public CacheKey | acquireDeferredLock(Object primaryKey, boolean isCacheCheckComplete)
Implements org. |
| public CacheKey | acquireLock(Object primaryKey, boolean forMerge, boolean isCacheCheckComplete)
Implements org. |
| public CacheKey | acquireLockNoWait(Object primaryKey, boolean forMerge)
Implements org. |
| public CacheKey | acquireLockWithWait(Object primaryKey, boolean forMerge, int wait)
Implements org. |
| public CacheKey | acquireReadLockOnCacheKey(Object primaryKey)
Implements org. |
| public CacheKey | acquireReadLockOnCacheKeyNoWait(Object primaryKey)
Implements org. |
| public abstract Object | clone()
Redeclares org. Overrides java. |
| public Enumeration | cloneKeys()
Implements org. CacheKey elements to be iterated.
|
| public void | collectLocks(HashMap<K, V> threadList)
Implements org. |
| public boolean | containsKey(Object
is the primary key for the object to search for. primaryKey)Implements org. |
| protected abstract CacheKeyInterceptor | |
| public Enumeration | elements()
Implements org. |
| public Object | get(Object primaryKey)
Implements org. |
| public abstract Map | Returns: Map of Entity PKs associated to the Entities that were retrievedList of Entity PKs to extract from the cache pkList, ClassDescriptor Descriptor type to be retrieved. descriptor, AbstractSession session)Redeclares org. |
| public abstract Map | Returns: Map of Entity PKs associated to the Entities that were retrievedList of Entity PKs to extract from the cache pkList, ClassDescriptor Descriptor type to be retrieved. descriptor, AbstractSession session)Redeclares org. |
| public CacheKey | getCacheKey(Object primaryKey, boolean forMerge)
Implements org. |
| public CacheKey | getCacheKeyForLock(Object primaryKey)
Implements org. |
| public ClassDescriptor | getDescriptor()
Implements org. |
| public Class | getDescriptorClass()
Implements org. |
| public int | Returns: The maxSize for the IdentityMap (NOTE: some subclasses may use this differently).Implements org. |
| public int | getSize()
Implements org. |
| public int | getSize(Class<?> myClass, boolean recurse)
Implements org. |
| public IdentityMap | |
| public Object | getWrapper(Object primaryKey)
Implements org. |
| public Object | getWriteLockValue(Object primaryKey)
Implements org. |
| public Enumeration | keys()
Implements org. CacheKey elements to be iterated.
|
| public Enumeration | keys(boolean checkReadLocks)
Implements org. CacheKey elements to be iterated.
|
| public void | lazyRelationshipLoaded(Object rootEntity, ValueHolderInterface<T> valueHolder, ForeignReferenceMapping mapping)
Implements org. |
| public CacheKey | put(Object
is the primary key for the object. primaryKey, Object is the domain object to cache. object, Object is the current write lock value of object, if null the version is ignored. writeLockValue, long readTime)Implements org. |
| public Object | remove(Object primaryKey, Object object)
Implements org. |
| public Object | remove(CacheKey cacheKey)
Implements org. |
| public void | setDescriptor(ClassDescriptor descriptor)
Implements org. |
| public void | setWrapper(Object primaryKey, Object wrapper)
Implements org. |
| public void | setWriteLockValue(Object primaryKey, Object writeLockValue)
Implements org. |
| public String | toString()
Overrides java. Implements org. |
| public void | updateMaxSize(int maxSize)
Implements org. |
| interceptedSession | back to summary |
|---|---|
| protected AbstractSession interceptedSession | |
| targetIdentityMap | back to summary |
|---|---|
| protected IdentityMap targetIdentityMap This attribute stores the actual IdentityMap as configured by the user. | |
| CacheInterceptor | back to summary |
|---|---|
| protected CacheInterceptor(IdentityMap targetIdentityMap, AbstractSession interceptedSession) | |
| acquireDeferredLock | back to summary |
|---|---|
| public CacheKey acquireDeferredLock(Object primaryKey, boolean isCacheCheckComplete) Implements org. 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.
| |
| acquireLock | back to summary |
|---|---|
| public CacheKey acquireLock(Object primaryKey, boolean forMerge, boolean isCacheCheckComplete) Implements org. Acquire an active lock on the object. This is used by reading (when using indirection or no relationships) and by merge.
| |
| acquireLockNoWait | back to summary |
|---|---|
| public CacheKey acquireLockNoWait(Object primaryKey, boolean forMerge) Implements org. Acquire an active lock on the object, if not already locked. This is used by merge for missing existing objects.
| |
| acquireLockWithWait | back to summary |
|---|---|
| public CacheKey acquireLockWithWait(Object primaryKey, boolean forMerge, int wait) Implements org. Acquire an active lock on the object, if not already locked. This is used by merge for missing existing objects.
| |
| acquireReadLockOnCacheKey | back to summary |
|---|---|
| public CacheKey acquireReadLockOnCacheKey(Object primaryKey) Implements org. Acquire a read lock on the object. This is used by UnitOfWork cloning. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held.
| |
| acquireReadLockOnCacheKeyNoWait | back to summary |
|---|---|
| public CacheKey acquireReadLockOnCacheKeyNoWait(Object primaryKey) Implements org. Acquire a read lock on the object, if not already locked. This is used by UnitOfWork cloning. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held.
| |
| clone | back to summary |
|---|---|
| public abstract Object clone() Redeclares org. Overrides java. Clone the map and all of the CacheKeys. This is used by UnitOfWork commitAndResumeOnFailure to avoid corrupting the cache during a failed commit.
| |
| cloneKeys | back to summary |
|---|---|
| public Enumeration Implements org. Allow for the
| |
| collectLocks | back to summary |
|---|---|
| public void collectLocks(HashMap<K, V> threadList) Implements org. Add all locked CacheKeys to the map grouped by thread. Used to print all the locks in the identity map.
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object primaryKey) Implements org. Return true if an CacheKey with the primary key is in the map. User API. | |
| createCacheKeyInterceptor | back to summary |
|---|---|
| protected abstract CacheKeyInterceptor createCacheKeyInterceptor(CacheKey wrappedCacheKey) | |
| elements | back to summary |
|---|---|
| public Enumeration Implements org. Allow for the cache to be iterated on. This method is only used during debugging when validateCache() has been called to print out the contents of the cache.
| |
| get | back to summary |
|---|---|
| public Object get(Object primaryKey) Implements org. Return the object cached in the identity map or null if it could not be found. User API.
| |
| getAllCacheKeysFromIdentityMapWithEntityPK | back to summary |
|---|---|
| public abstract Map Redeclares org. 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. | |
| getAllFromIdentityMapWithEntityPK | back to summary |
|---|---|
| public abstract Map Redeclares org. 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. | |
| getCacheKey | back to summary |
|---|---|
| public CacheKey getCacheKey(Object primaryKey, boolean forMerge) Implements org. Get the cache key (with object) for the primary key.
| |
| getCacheKeyForLock | back to summary |
|---|---|
| public CacheKey getCacheKeyForLock(Object primaryKey) Implements org. Get the cache key (with object) for the primary key.
| |
| getDescriptor | back to summary |
|---|---|
| public ClassDescriptor getDescriptor() Implements org. Return the descriptor that this is the map for.
| |
| getDescriptorClass | back to summary |
|---|---|
| public Class Implements org. Return the class that this is the map for.
| |
| getMaxSize | back to summary |
|---|---|
| public int getMaxSize() Implements org.
| |
| getSize | back to summary |
|---|---|
| public int getSize() Implements org. Return the number of CacheKeys in the IdentityMap. This may contain weak referenced objects that have been garbage collected.
| |
| getSize | back to summary |
|---|---|
| public int getSize(Class<?> myClass, boolean recurse) Implements org. Return the number of actual objects of type myClass in the IdentityMap. Recurse = true will include subclasses of myClass in the count.
| |
| getTargetIdenttyMap | back to summary |
|---|---|
| public IdentityMap getTargetIdenttyMap() Return the instance of the IdentityMap that this intercpetor is wrapping. Any call that is to be passed on to the underlying EclipseLink cache should be passed to this IdentityMap. | |
| getWrapper | back to summary |
|---|---|
| public Object getWrapper(Object primaryKey) Implements org. Get the wrapper object from the cache key associated with the given primary key, this is used for EJB2.
| |
| getWriteLockValue | back to summary |
|---|---|
| public Object getWriteLockValue(Object primaryKey) Implements org. Get the write lock value from the cache key associated to the primarykey. User API.
| |
| keys | back to summary |
|---|---|
| public Enumeration Implements org. Allow for the
| |
| keys | back to summary |
|---|---|
| public Enumeration Implements org. Allow for the
| |
| lazyRelationshipLoaded | back to summary |
|---|---|
| public void lazyRelationshipLoaded(Object rootEntity, ValueHolderInterface<T> valueHolder, ForeignReferenceMapping mapping) Implements org. Notify the cache that a lazy relationship has been triggered in the object and the cache may need to be updated
| |
| put | back to summary |
|---|---|
| public CacheKey put(Object primaryKey, Object object, Object writeLockValue, long readTime) Implements org. 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. | |
| remove | back to summary |
|---|---|
| public Object remove(Object primaryKey, Object object) Implements org. Remove the CacheKey with the primaryKey from the map. This is used by DeleteObjectQuery and merge. This is also an advanced (very) user API.
| |
| remove | back to summary |
|---|---|
| public Object remove(CacheKey cacheKey) Implements org. Remove the CacheKey from the map.
| |
| setDescriptor | back to summary |
|---|---|
| public void setDescriptor(ClassDescriptor descriptor) Implements org. Set the descriptor that this is the map for.
| |
| setWrapper | back to summary |
|---|---|
| public void setWrapper(Object primaryKey, Object wrapper) Implements org. Update the wrapper object in the CacheKey associated with the given primaryKey, this is used for EJB2.
| |
| setWriteLockValue | back to summary |
|---|---|
| public void setWriteLockValue(Object primaryKey, Object writeLockValue) Implements org. Update the write lock value of the CacheKey associated with the given primaryKey. This is used by UpdateObjectQuery, and is also an advanced (very) user API.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements org. Doc from java. Returns a string representation of the object. | |
| updateMaxSize | back to summary |
|---|---|
| public void updateMaxSize(int maxSize) Implements org. This method will be used to update the max cache size, any objects exceeding the max cache size will be remove from the cache. Please note that this does not remove the object from the identityMap, except in the case of the CacheIdentityMap.
| |