org.eclipse.persistence.sessions.interceptors
Class CacheKeyInterceptor

java.lang.Object
  extended by org.eclipse.persistence.internal.identitymaps.CacheKey
      extended by org.eclipse.persistence.sessions.interceptors.CacheKeyInterceptor
All Implemented Interfaces:
Serializable, Cloneable

public class CacheKeyInterceptor
extends org.eclipse.persistence.internal.identitymaps.CacheKey

The CacheKeyInterceptor allows a Cache Interceptor implementation to wrap the EclipseLink CacheKey. The CacheKey is an object that wraps the object and maintains cached based information about the object like primary key, write lock value and locking. The EclipseLink runtime will access the CacheKey and directly when releasing locks.

Author:
Gordon Yorke
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.eclipse.persistence.internal.identitymaps.CacheKey
CACHE_KEY_INVALID, CHECK_INVALIDATION_POLICY, MAX_WAIT_TRIES
 
Constructor Summary
CacheKeyInterceptor(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey)
           
 
Method Summary
 void acquire()
          Acquire the lock on the cache key object.
 void acquire(boolean forMerge)
          Acquire the lock on the cache key object.
 void acquireDeferredLock()
          Acquire the deferred lock.
 boolean acquireIfUnownedNoWait()
          Acquire the lock on the cache key object.
 boolean acquireNoWait()
          Acquire the lock on the cache key object.
 boolean acquireNoWait(boolean forMerge)
          Acquire the lock on the cache key object.
 void acquireReadLock()
          Acquire the read lock on the cache key object.
 boolean acquireReadLockNoWait()
          Acquire the read lock on the cache key object.
 void checkDeferredLock()
          Check the deferred lock on the cache key object.
 void checkReadLock()
          Check the read lock on the cache key object.
 Object clone()
          INTERNAL: Clones itself.
 boolean equals(org.eclipse.persistence.internal.identitymaps.CacheKey key)
          Determine if the receiver is equal to key.
 int getInvalidationState()
          INTERNAL: Return the value of the invalidationState Variable The return value will be a constant CHECK_INVALIDATION_POLICY - The Invalidation policy is must be checked for this cache key's sate CACHE_KEY_INVALID - This cache key has been labeled invalid.
 Object getKey()
           
 long getLastUpdatedQueryId()
          INTERNAL: This method returns the system time in millis seconds at which this object was last refreshed CR #4365 CR #2698903 ...
 org.eclipse.persistence.internal.helper.ConcurrencyManager getMutex()
          Return the concurrency manager.
 Object getObject()
           
 org.eclipse.persistence.internal.identitymaps.IdentityMap getOwningMap()
           
 long getReadTime()
          INTERNAL: Return the current value of the Read Time variable
 Record getRecord()
           
 org.eclipse.persistence.internal.identitymaps.CacheKey getWrappedCacheKey()
          If a Wrapper subclasses this CacheKey this method will be used to unwrap the cache key.
 Object getWrapper()
           
 Object getWriteLockValue()
           
 int hashCode()
          Overrides hashCode() in Object to use the primaryKey's hashCode for storage in data structures.
 boolean isAcquired()
          Return if the lock is acquired
 void release()
          Release the lock on the cache key object.
 void releaseDeferredLock()
          Release the deferred lock
 void releaseReadLock()
          Release the read lock on the cache key object.
 Object removeFromOwningMap()
          Removes this cacheKey from the owning map
 void setInvalidationState(int invalidationState)
          INTERNAL: Set the value of the invalidationState Variable The possible values are from an enumeration of constants CHECK_INVALIDATION_POLICY - The invalidation policy is must be checked for this cache key's sate CACHE_KEY_INVALID - This cache key has been labelled invalid.
 void setKey(Vector key)
           
 void setLastUpdatedQueryId(long id)
          INTERNAL: This method sets the system time in millis seconds at which this object was last refreshed CR #4365 CR #2698903 ...
 void setMutex(org.eclipse.persistence.internal.helper.ConcurrencyManager mutex)
          Set the concurrency manager.
 void setObject(Object object)
           
 void setOwningMap(org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap map)
           
 void setReadTime(long readTime)
          INTERNAL: Set the read time of this cache key
 void setRecord(Record newRecord)
           
 void setWrapper(Object wrapper)
           
 void setWriteLockValue(Object writeLockValue)
           
 String toString()
           
 void updateAccess()
          Notifies that cache key that it has been accessed.
 
Methods inherited from class org.eclipse.persistence.internal.identitymaps.CacheKey
acquireWithWait, equals, isWrapper, setIsWrapper, setKey, setOwningMap, transitionToDeferredLock, waitForObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheKeyInterceptor

public CacheKeyInterceptor(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey)
Method Detail

acquire

public void acquire()
Acquire the lock on the cache key object.

Overrides:
acquire in class org.eclipse.persistence.internal.identitymaps.CacheKey

acquire

public void acquire(boolean forMerge)
Acquire the lock on the cache key object. For the merge process called with true from the merge process, if true then the refresh will not refresh the object

Overrides:
acquire in class org.eclipse.persistence.internal.identitymaps.CacheKey

acquireNoWait

public boolean acquireNoWait()
Acquire the lock on the cache key object. But only if the object has no lock on it Added for CR 2317

Overrides:
acquireNoWait in class org.eclipse.persistence.internal.identitymaps.CacheKey

acquireIfUnownedNoWait

public boolean acquireIfUnownedNoWait()
Acquire the lock on the cache key object. Only acquire a lock if the cache key's active thread is not set. Added for Bug 5840635

Overrides:
acquireIfUnownedNoWait in class org.eclipse.persistence.internal.identitymaps.CacheKey

acquireNoWait

public boolean acquireNoWait(boolean forMerge)
Acquire the lock on the cache key object. But only if the object has no lock on it Added for CR 2317 called with true from the merge process, if true then the refresh will not refresh the object

Overrides:
acquireNoWait in class org.eclipse.persistence.internal.identitymaps.CacheKey

acquireDeferredLock

public void acquireDeferredLock()
Acquire the deferred lock.

Overrides:
acquireDeferredLock in class org.eclipse.persistence.internal.identitymaps.CacheKey

checkReadLock

public void checkReadLock()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
Check the read lock on the cache key object. This can be called to ensure the cache key has a valid built object. It does not hold a lock, so the object could be refreshed afterwards.

Overrides:
checkReadLock in class org.eclipse.persistence.internal.identitymaps.CacheKey

checkDeferredLock

public void checkDeferredLock()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
Check the deferred lock on the cache key object. This can be called to ensure the cache key has a valid built object. It does not hold a lock, so the object could be refreshed afterwards.

Overrides:
checkDeferredLock in class org.eclipse.persistence.internal.identitymaps.CacheKey

acquireReadLock

public void acquireReadLock()
Acquire the read lock on the cache key object.

Overrides:
acquireReadLock in class org.eclipse.persistence.internal.identitymaps.CacheKey

acquireReadLockNoWait

public boolean acquireReadLockNoWait()
Acquire the read lock on the cache key object.

Overrides:
acquireReadLockNoWait in class org.eclipse.persistence.internal.identitymaps.CacheKey

clone

public Object clone()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
INTERNAL: Clones itself.

Overrides:
clone in class org.eclipse.persistence.internal.identitymaps.CacheKey

equals

public boolean equals(org.eclipse.persistence.internal.identitymaps.CacheKey key)
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
Determine if the receiver is equal to key. Use an index compare, because it is much faster than enumerations.

Overrides:
equals in class org.eclipse.persistence.internal.identitymaps.CacheKey

getLastUpdatedQueryId

public long getLastUpdatedQueryId()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
INTERNAL: This method returns the system time in millis seconds at which this object was last refreshed CR #4365 CR #2698903 ... instead of using millis we will now use id's instead. Method renamed appropriately.

Overrides:
getLastUpdatedQueryId in class org.eclipse.persistence.internal.identitymaps.CacheKey

getKey

public Object getKey()
Overrides:
getKey in class org.eclipse.persistence.internal.identitymaps.CacheKey

getMutex

public org.eclipse.persistence.internal.helper.ConcurrencyManager getMutex()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
Return the concurrency manager.

Overrides:
getMutex in class org.eclipse.persistence.internal.identitymaps.CacheKey

getObject

public Object getObject()
Overrides:
getObject in class org.eclipse.persistence.internal.identitymaps.CacheKey

getOwningMap

public org.eclipse.persistence.internal.identitymaps.IdentityMap getOwningMap()
Overrides:
getOwningMap in class org.eclipse.persistence.internal.identitymaps.CacheKey

getReadTime

public long getReadTime()
INTERNAL: Return the current value of the Read Time variable

Overrides:
getReadTime in class org.eclipse.persistence.internal.identitymaps.CacheKey

getRecord

public Record getRecord()
Overrides:
getRecord in class org.eclipse.persistence.internal.identitymaps.CacheKey

getWrappedCacheKey

public org.eclipse.persistence.internal.identitymaps.CacheKey getWrappedCacheKey()
If a Wrapper subclasses this CacheKey this method will be used to unwrap the cache key.

Overrides:
getWrappedCacheKey in class org.eclipse.persistence.internal.identitymaps.CacheKey
Returns:

getWrapper

public Object getWrapper()
Overrides:
getWrapper in class org.eclipse.persistence.internal.identitymaps.CacheKey

getWriteLockValue

public Object getWriteLockValue()
Overrides:
getWriteLockValue in class org.eclipse.persistence.internal.identitymaps.CacheKey

hashCode

public int hashCode()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
Overrides hashCode() in Object to use the primaryKey's hashCode for storage in data structures.

Overrides:
hashCode in class org.eclipse.persistence.internal.identitymaps.CacheKey

isAcquired

public boolean isAcquired()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
Return if the lock is acquired

Overrides:
isAcquired in class org.eclipse.persistence.internal.identitymaps.CacheKey

getInvalidationState

public int getInvalidationState()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
INTERNAL: Return the value of the invalidationState Variable The return value will be a constant CHECK_INVALIDATION_POLICY - The Invalidation policy is must be checked for this cache key's sate CACHE_KEY_INVALID - This cache key has been labeled invalid.

Overrides:
getInvalidationState in class org.eclipse.persistence.internal.identitymaps.CacheKey

release

public void release()
Release the lock on the cache key object.

Overrides:
release in class org.eclipse.persistence.internal.identitymaps.CacheKey

releaseDeferredLock

public void releaseDeferredLock()
Release the deferred lock

Overrides:
releaseDeferredLock in class org.eclipse.persistence.internal.identitymaps.CacheKey

releaseReadLock

public void releaseReadLock()
Release the read lock on the cache key object.

Overrides:
releaseReadLock in class org.eclipse.persistence.internal.identitymaps.CacheKey

removeFromOwningMap

public Object removeFromOwningMap()
Removes this cacheKey from the owning map

Overrides:
removeFromOwningMap in class org.eclipse.persistence.internal.identitymaps.CacheKey

setInvalidationState

public void setInvalidationState(int invalidationState)
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
INTERNAL: Set the value of the invalidationState Variable The possible values are from an enumeration of constants CHECK_INVALIDATION_POLICY - The invalidation policy is must be checked for this cache key's sate CACHE_KEY_INVALID - This cache key has been labelled invalid.

Overrides:
setInvalidationState in class org.eclipse.persistence.internal.identitymaps.CacheKey

setLastUpdatedQueryId

public void setLastUpdatedQueryId(long id)
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
INTERNAL: This method sets the system time in millis seconds at which this object was last refreshed CR #4365 CR #2698903 ... instead of using millis we will now use ids instead. Method renamed appropriately.

Overrides:
setLastUpdatedQueryId in class org.eclipse.persistence.internal.identitymaps.CacheKey

setKey

public void setKey(Vector key)

setMutex

public void setMutex(org.eclipse.persistence.internal.helper.ConcurrencyManager mutex)
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
Set the concurrency manager.

Overrides:
setMutex in class org.eclipse.persistence.internal.identitymaps.CacheKey

setObject

public void setObject(Object object)
Overrides:
setObject in class org.eclipse.persistence.internal.identitymaps.CacheKey

setOwningMap

public void setOwningMap(org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap map)

setReadTime

public void setReadTime(long readTime)
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
INTERNAL: Set the read time of this cache key

Overrides:
setReadTime in class org.eclipse.persistence.internal.identitymaps.CacheKey

setRecord

public void setRecord(Record newRecord)
Overrides:
setRecord in class org.eclipse.persistence.internal.identitymaps.CacheKey

setWrapper

public void setWrapper(Object wrapper)
Overrides:
setWrapper in class org.eclipse.persistence.internal.identitymaps.CacheKey

setWriteLockValue

public void setWriteLockValue(Object writeLockValue)
Overrides:
setWriteLockValue in class org.eclipse.persistence.internal.identitymaps.CacheKey

toString

public String toString()
Overrides:
toString in class org.eclipse.persistence.internal.identitymaps.CacheKey

updateAccess

public void updateAccess()
Description copied from class: org.eclipse.persistence.internal.identitymaps.CacheKey
Notifies that cache key that it has been accessed. Allows the LRU sub-cache to be maintained.

Overrides:
updateAccess in class org.eclipse.persistence.internal.identitymaps.CacheKey