Top Description Fields Constructors Methods
org.eclipse.persistence.internal.identitymaps

public Class CacheKey

extends ConcurrencyManager
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
org.eclipse.persistence.internal.identitymaps.LinkedCacheKey, org.eclipse.persistence.internal.identitymaps.WeakCacheKey, org.eclipse.persistence.sessions.interceptors.CacheKeyInterceptor
Imports
org.eclipse.persistence.exceptions.ConcurrencyException, org.eclipse.persistence.internal.helper.*, org.eclipse.persistence.internal.sessions.AbstractRecord, org.eclipse.persistence.queries.ObjectBuildingQuery, org.eclipse.persistence.sessions.DataRecord, .DatabaseRecord

Purpose: Container class for storing objects in an IdentityMap.

Responsibilities:

Since
TOPLink/Java 1.0

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
CHECK_INVALIDATION_POLICY

The following constants are used for the invalidationState variable

public final long
public final long
public final String
protected DataRecord
dataRecord

This is used for Document Preservation to cache the record that this object was built from

protected int
invalidationState

Invalidation State can be used to indicate whether this cache key is considered valid

protected boolean
isIsolated

Set to true if this CacheKey comes from an IsolatedClientSession, or DatabaseSessionImpl.

protected boolean
isWrapper

Stores if this CacheKey instance is a wrapper for the underlying CacheKey.

protected Object
key

The key holds the vector of primary key values for the object.

protected long
lastUpdatedQueryId

This attribute is the system time in milli seconds that the object was last refreshed on

protected IdentityMap
public static final int
protected Object
protected AbstractRecord
protectedForeignKeys

Stores retrieved FK values for relationships that are not stored in the Entity

protected long
readTime

The read time stores the millisecond value of the last time the object help by this cache key was confirmed as up to date.

protected Object
transactionId

The ID of the database transaction that last wrote the object.

protected Object
wrapper

The cached wrapper for the object, used in EJB.

protected Object
writeLockValue

The writeLock value is being held as an object so that it might contain a number or timestamp.

Inherited from org.eclipse.persistence.internal.helper.ConcurrencyManager:
activeThreadDEFERRED_LOCK_MANAGERSdepthlockedByMergeManagernumberOfReadersnumberOfWritersWaitingshouldTrackStackstack

Constructor Summary

AccessConstructor and Description
protected
CacheKey()

Internal: Only used by subclasses that may want to wrap the cache key.

public
CacheKey(Object primaryKey)

public
CacheKey(Object primaryKey, Object object, Object lockValue)

public
CacheKey(Object primaryKey, Object object, Object lockValue, long readTime, boolean isIsolated)

Method Summary

Modifier and TypeMethod and Description
public void
acquire()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquire.

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

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquire.

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

Acquire the lock on the cache key object.

public void
public boolean
public boolean
acquireNoWait(boolean forMerge)

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireNoWait.

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

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireReadLock.

Acquire the read lock on the cache key object.
public boolean
public boolean
acquireWithWait(boolean forMerge, int wait)

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireWithWait.

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

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.checkDeferredLock.

Check the deferred lock on the cache key object.
public void
checkReadLock()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.checkReadLock.

Check the read lock on the cache key object.
public Object
clone()

Overrides java.lang.Object.clone.

INTERNAL: Clones itself.
public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides java.lang.Object.equals.

Determine if the receiver is equal to anObject.
public boolean
equals(CacheKey key)

Determine if the receiver is equal to key.

public Thread
public 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.

public Object
public long
getLastUpdatedQueryId()

INTERNAL: This method returns the system time in millis seconds at which this object was last refreshed CR #4365 CR #2698903 ...

public Object
public IdentityMap
public AbstractRecord
getProtectedForeignKeys()

INTERNAL: Return the FK cache

public long
getReadTime()

INTERNAL: Return the current value of the Read Time variable

public DataRecord
public Object
public CacheKey
getWrappedCacheKey()

If a Wrapper subclasses this CacheKey this method will be used to unwrap the cache key.

public Object
public Object
public int
hashCode()

Overrides java.lang.Object.hashCode.

Overrides hashCode() in Object to use the primaryKey's hashCode for storage in data structures.
public boolean
hasProtectedForeignKeys()

Returns true if the protectedForeignKeys record is non-null and non-empty, false otherwise.

public boolean
isIsolated()

Returns true if this CacheKey is from an IsolatedClientSession

public boolean
isWrapper()

Returns true if this Instance of CacheKey is a wrapper and should be unwrapped before passing to IdentityMap APIs.

public void
release()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.release.

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

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.releaseReadLock.

Release the read lock on the cache key object.
public Object
removeFromOwningMap()

Removes this cacheKey from the owning map

public 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.

public void
setIsolated(boolean isIsolated)

public void
setIsWrapper(boolean isWrapper)

public void
public 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 ...

public void
setObject(Object object)

public void
public void
public void
setReadTime(long readTime)

INTERNAL: Set the read time of this cache key

public void
setRecord(DataRecord newDataRecord)

public void
setTransactionId(Object transactionId)

public void
setWrapper(Object wrapper)

public void
setWriteLockValue(Object writeLockValue)

public String
public void
updateAccess()

Notifies that cache key that it has been accessed.

public synchronized Object
Inherited from org.eclipse.persistence.internal.helper.ConcurrencyManager:
acquireIfUnownedNoWaitaddReadLockToReadLockManagerclearJustificationWhyMethodIsBuildingObjectCompleteReturnsFalseenrichStringBuildingExplainWhyThreadIsStuckInIsBuildObjectOnThreadCompletegetConcurrencyManagerCreationDategetConcurrencyManagerIdgetDeferredLockManagergetDeferredLockManagersgetDepthgetNumberOfReadersgetNumberOfWritersWaitinggetReadLockManagergetReadLockManagerEnsureResultIsNotNullgetReadLockManagersgetStackgetThreadsToWaitOnAcquiregetThreadsToWaitOnAcquireMethodNamegetThreadsToWaitOnAcquireReadLockgetThreadsToWaitOnAcquireReadLockMethodNamegetThreadsWaitingToReleaseDeferredLocksgetThreadsWaitingToReleaseDeferredLocksJustificationgetTotalNumberOfKeysAcquiredForReadinggetTotalNumberOfKeysReleasedForReadinggetTotalNumberOfKeysReleasedForReadingBlewUpExceptionDueToCacheKeyHavingReachedCounterZeroinitializeDeferredLockManagersisAcquiredisBuildObjectOnThreadCompleteisLockedByMergeManagerisNestedputDeferredLockputThreadAsWaitingToAcquireLockForReadingputThreadAsWaitingToAcquireLockForWritingreleaseAllLocksAcquiredByThreadremoveDeferredLockManagerremoveReadLockFromReadLockManagerremoveReadLockManagerIfEmptyremoveThreadNoLongerWaitingToAcquireLockForReadingremoveThreadNoLongerWaitingToAcquireLockForWritingsetActiveThreadsetDepthsetIsLockedByMergeManagersetJustificationWhyMethodIsBuildingObjectCompleteReturnsFalsesetNumberOfReaderssetNumberOfWritersWaitingsetShouldTrackStacksetStackshouldTrackStacktransitionToDeferredLock

Field Detail

CACHE_KEY_INVALIDback to summary
public static final int CACHE_KEY_INVALID
CHECK_INVALIDATION_POLICYback to summary
public static final int CHECK_INVALIDATION_POLICY

The following constants are used for the invalidationState variable

CREATION_THREAD_HASHCODEback to summary
public final long CREATION_THREAD_HASHCODE
CREATION_THREAD_IDback to summary
public final long CREATION_THREAD_ID
CREATION_THREAD_NAMEback to summary
public final String CREATION_THREAD_NAME
dataRecordback to summary
protected DataRecord dataRecord

This is used for Document Preservation to cache the record that this object was built from

invalidationStateback to summary
protected int invalidationState

Invalidation State can be used to indicate whether this cache key is considered valid

isIsolatedback to summary
protected boolean isIsolated

Set to true if this CacheKey comes from an IsolatedClientSession, or DatabaseSessionImpl.

isWrapperback to summary
protected boolean isWrapper

Stores if this CacheKey instance is a wrapper for the underlying CacheKey. CacheKey wrappers may be used with cache interceptors.

keyback to summary
protected Object key

The key holds the vector of primary key values for the object.

lastUpdatedQueryIdback to summary
protected long lastUpdatedQueryId

This attribute is the system time in milli seconds that the object was last refreshed on

mapOwnerback to summary
protected IdentityMap mapOwner
MAX_WAIT_TRIESback to summary
public static final int MAX_WAIT_TRIES
objectback to summary
protected Object object
protectedForeignKeysback to summary
protected AbstractRecord protectedForeignKeys

Stores retrieved FK values for relationships that are not stored in the Entity

readTimeback to summary
protected long readTime

The read time stores the millisecond value of the last time the object help by this cache key was confirmed as up to date.

transactionIdback to summary
protected Object transactionId

The ID of the database transaction that last wrote the object. This is used for database change notification.

wrapperback to summary
protected Object wrapper

The cached wrapper for the object, used in EJB.

writeLockValueback to summary
protected Object writeLockValue

The writeLock value is being held as an object so that it might contain a number or timestamp.

Constructor Detail

CacheKeyback to summary
protected CacheKey()

Internal: Only used by subclasses that may want to wrap the cache key. Could be replaced by switching to an interface.

CacheKeyback to summary
public CacheKey(Object primaryKey)
CacheKeyback to summary
public CacheKey(Object primaryKey, Object object, Object lockValue)
CacheKeyback to summary
public CacheKey(Object primaryKey, Object object, Object lockValue, long readTime, boolean isIsolated)

Method Detail

acquireback to summary
public void acquire()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquire.

Acquire the lock on the cache key object.

Annotations
@Override
acquireback to summary
public void acquire(boolean forMerge)

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquire.

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

Annotations
@Override
acquireDeferredLockback to summary
public void acquireDeferredLock()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireDeferredLock.

Acquire the deferred lock.

Annotations
@Override
acquireIfUnownedNoWaitback to summary
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

acquireLockback to summary
public void acquireLock(ObjectBuildingQuery query)
acquireNoWaitback to summary
public boolean acquireNoWait()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireNoWait.

Acquire the lock on the cache key object. But only if the object has no lock on it Added for CR 2317

Annotations
@Override
acquireNoWaitback to summary
public boolean acquireNoWait(boolean forMerge)

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireNoWait.

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

Annotations
@Override
acquireReadLockback to summary
public void acquireReadLock()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireReadLock.

Acquire the read lock on the cache key object.

Annotations
@Override
acquireReadLockNoWaitback to summary
public boolean acquireReadLockNoWait()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireReadLockNoWait.

Acquire the read lock on the cache key object. Return true if acquired.

Annotations
@Override
acquireWithWaitback to summary
public boolean acquireWithWait(boolean forMerge, int wait)

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.acquireWithWait.

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

Annotations
@Override
checkDeferredLockback to summary
public void checkDeferredLock()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.checkDeferredLock.

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.

Annotations
@Override
checkReadLockback to summary
public void checkReadLock()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.checkReadLock.

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.

Annotations
@Override
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

INTERNAL: Clones itself.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Determine if the receiver is equal to anObject. If anObject is a CacheKey, do further comparison, otherwise, return false.

Parameters
object:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
See Also
CacheKey#equals(CacheKey)
equalsback to summary
public boolean equals(CacheKey key)

Determine if the receiver is equal to key. Use an index compare, because it is much faster than enumerations.

getActiveThreadback to summary
public Thread getActiveThread()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.getActiveThread.

Return the active thread.

Annotations
@Override
getInvalidationStateback to summary
public 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.

getKeyback to summary
public Object getKey()
getLastUpdatedQueryIdback to summary
public long getLastUpdatedQueryId()

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.

getObjectback to summary
public Object getObject()
getOwningMapback to summary
public IdentityMap getOwningMap()
getProtectedForeignKeysback to summary
public AbstractRecord getProtectedForeignKeys()

INTERNAL: Return the FK cache

getReadTimeback to summary
public long getReadTime()

INTERNAL: Return the current value of the Read Time variable

getRecordback to summary
public DataRecord getRecord()
getTransactionIdback to summary
public Object getTransactionId()
getWrappedCacheKeyback to summary
public CacheKey getWrappedCacheKey()

If a Wrapper subclasses this CacheKey this method will be used to unwrap the cache key.

getWrapperback to summary
public Object getWrapper()
getWriteLockValueback to summary
public Object getWriteLockValue()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Overrides hashCode() in Object to use the primaryKey's hashCode for storage in data structures.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
hasProtectedForeignKeysback to summary
public boolean hasProtectedForeignKeys()

Returns true if the protectedForeignKeys record is non-null and non-empty, false otherwise.

isIsolatedback to summary
public boolean isIsolated()

Returns true if this CacheKey is from an IsolatedClientSession

isWrapperback to summary
public boolean isWrapper()

Returns true if this Instance of CacheKey is a wrapper and should be unwrapped before passing to IdentityMap APIs. Wrapped CacheKeys may be used in the Cache Interceptors.

releaseback to summary
public void release()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.release.

Release the lock on the cache key object.

Annotations
@Override
releaseDeferredLockback to summary
public void releaseDeferredLock()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.releaseDeferredLock.

Release the deferred lock

Annotations
@Override
releaseReadLockback to summary
public void releaseReadLock()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.releaseReadLock.

Release the read lock on the cache key object.

Annotations
@Override
removeFromOwningMapback to summary
public Object removeFromOwningMap()

Removes this cacheKey from the owning map

setInvalidationStateback to summary
public 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.

setIsolatedback to summary
public void setIsolated(boolean isIsolated)
setIsWrapperback to summary
public void setIsWrapper(boolean isWrapper)
setKeyback to summary
public void setKey(Object key)
setLastUpdatedQueryIdback to summary
public 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 ... instead of using millis we will now use ids instead. Method renamed appropriately.

setObjectback to summary
public void setObject(Object object)
setOwningMapback to summary
public void setOwningMap(IdentityMap map)
setProtectedForeignKeysback to summary
public void setProtectedForeignKeys(AbstractRecord protectedForeignKeys)
setReadTimeback to summary
public void setReadTime(long readTime)

INTERNAL: Set the read time of this cache key

setRecordback to summary
public void setRecord(DataRecord newDataRecord)
setTransactionIdback to summary
public void setTransactionId(Object transactionId)
setWrapperback to summary
public void setWrapper(Object wrapper)
setWriteLockValueback to summary
public void setWriteLockValue(Object writeLockValue)
toStringback to summary
public String toString()

Overrides org.eclipse.persistence.internal.helper.ConcurrencyManager.toString.

Doc from org.eclipse.persistence.internal.helper.ConcurrencyManager.toString.

Print the nested depth.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
updateAccessback to summary
public void updateAccess()

Notifies that cache key that it has been accessed. Allows the LRU sub-cache to be maintained.

waitForObjectback to summary
public synchronized Object waitForObject()