Module org.eclipse.persistence.core
Class CacheKey
java.lang.Object
org.eclipse.persistence.internal.helper.ConcurrencyManager
org.eclipse.persistence.internal.identitymaps.CacheKey
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
CacheKeyInterceptor
,LinkedCacheKey
,WeakCacheKey
Purpose: Container class for storing objects in an IdentityMap.
Responsibilities:
- Hold key and object.
- Maintain and update the current writeLockValue.
- Since:
- TOPLink/Java 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
The following constants are used for the invalidationState variablefinal long
final long
final String
protected DataRecord
This is used for Document Preservation to cache the record that this object was built fromprotected int
Invalidation State can be used to indicate whether this cache key is considered validprotected boolean
Set to true if this CacheKey comes from an IsolatedClientSession, or DatabaseSessionImpl.protected boolean
Stores if this CacheKey instance is a wrapper for the underlying CacheKey.protected Object
The key holds the vector of primary key values for the object.protected long
This attribute is the system time in milli seconds that the object was last refreshed onprotected IdentityMap
static final int
protected Object
protected AbstractRecord
Stores retrieved FK values for relationships that are not stored in the Entityprotected long
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
The ID of the database transaction that last wrote the object.protected Object
The cached wrapper for the object, used in EJB.protected Object
The writeLock value is being held as an object so that it might contain a number or timestamp.Fields inherited from class org.eclipse.persistence.internal.helper.ConcurrencyManager
activeThread, DEFERRED_LOCK_MANAGERS, depth, lockedByMergeManager, numberOfReaders, numberOfWritersWaiting, shouldTrackStack, stack
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CacheKey()
Internal: Only used by subclasses that may want to wrap the cache key. -
Method Summary
Modifier and TypeMethodDescriptionvoid
acquire()
Acquire the lock on the cache key object.void
acquire
(boolean forMerge) Acquire the lock on the cache key object.void
Acquire the deferred lock.boolean
Acquire the lock on the cache key object.void
acquireLock
(ObjectBuildingQuery query) boolean
Acquire the lock on the cache key object.boolean
acquireNoWait
(boolean forMerge) Acquire the lock on the cache key object.void
Acquire the read lock on the cache key object.boolean
Acquire the read lock on the cache key object.boolean
acquireWithWait
(boolean forMerge, int wait) Acquire the lock on the cache key object.void
Check the deferred lock on the cache key object.void
Check the read lock on the cache key object.clone()
INTERNAL: Clones itself.boolean
Determine if the receiver is equal to anObject.boolean
Determine if the receiver is equal to key.Return the active thread.int
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.getKey()
long
INTERNAL: This method returns the system time in millis seconds at which this object was last refreshed CR #4365 CR #2698903 ...INTERNAL: Return the FK cachelong
INTERNAL: Return the current value of the Read Time variableIf a Wrapper subclasses this CacheKey this method will be used to unwrap the cache key.int
hashCode()
Overrides hashCode() in Object to use the primaryKey's hashCode for storage in data structures.boolean
Returns true if the protectedForeignKeys record is non-null and non-empty, false otherwise.boolean
Returns true if this CacheKey is from an IsolatedClientSessionboolean
Returns true if this Instance of CacheKey is a wrapper and should be unwrapped before passing to IdentityMap APIs.void
release()
Release the lock on the cache key object.void
Release the deferred lockvoid
Release the read lock on the cache key object.Removes this cacheKey from the owning mapvoid
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
setIsolated
(boolean isIsolated) void
setIsWrapper
(boolean isWrapper) void
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
void
setOwningMap
(IdentityMap map) void
setProtectedForeignKeys
(AbstractRecord protectedForeignKeys) void
setReadTime
(long readTime) INTERNAL: Set the read time of this cache keyvoid
setRecord
(DataRecord newDataRecord) void
setTransactionId
(Object transactionId) void
setWrapper
(Object wrapper) void
setWriteLockValue
(Object writeLockValue) toString()
Print the nested depth.void
Notifies that cache key that it has been accessed.Methods inherited from class org.eclipse.persistence.internal.helper.ConcurrencyManager
acquireIfUnownedNoWait, addReadLockToReadLockManager, clearJustificationWhyMethodIsBuildingObjectCompleteReturnsFalse, enrichStringBuildingExplainWhyThreadIsStuckInIsBuildObjectOnThreadComplete, getConcurrencyManagerCreationDate, getConcurrencyManagerId, getDeferredLockManager, getDeferredLockManagers, getDepth, getInstanceLock, getInstanceLockCondition, getNumberOfReaders, getNumberOfWritersWaiting, getReadLockManager, getReadLockManagerEnsureResultIsNotNull, getReadLockManagers, getStack, getThreadsToWaitOnAcquire, getThreadsToWaitOnAcquireMethodName, getThreadsToWaitOnAcquireReadLock, getThreadsToWaitOnAcquireReadLockMethodName, getThreadsWaitingToReleaseDeferredLocks, getThreadsWaitingToReleaseDeferredLocksJustification, getTotalNumberOfKeysAcquiredForReading, getTotalNumberOfKeysReleasedForReading, getTotalNumberOfKeysReleasedForReadingBlewUpExceptionDueToCacheKeyHavingReachedCounterZero, initializeDeferredLockManagers, isAcquired, isBuildObjectOnThreadComplete, isLockedByMergeManager, isNested, putDeferredLock, putThreadAsWaitingToAcquireLockForReading, putThreadAsWaitingToAcquireLockForWriting, releaseAllLocksAcquiredByThread, removeDeferredLockManager, removeReadLockFromReadLockManager, removeReadLockManagerIfEmpty, removeThreadNoLongerWaitingToAcquireLockForReading, removeThreadNoLongerWaitingToAcquireLockForWriting, setActiveThread, setDepth, setIsLockedByMergeManager, setJustificationWhyMethodIsBuildingObjectCompleteReturnsFalse, setNumberOfReaders, setNumberOfWritersWaiting, setShouldTrackStack, setStack, shouldTrackStack, transitionToDeferredLock
-
Field Details
-
CREATION_THREAD_ID
public final long CREATION_THREAD_ID -
CREATION_THREAD_NAME
-
CREATION_THREAD_HASHCODE
public final long CREATION_THREAD_HASHCODE -
key
The key holds the vector of primary key values for the object. -
object
-
mapOwner
-
writeLockValue
The writeLock value is being held as an object so that it might contain a number or timestamp. -
wrapper
The cached wrapper for the object, used in EJB. -
dataRecord
This is used for Document Preservation to cache the record that this object was built from -
lastUpdatedQueryId
protected long lastUpdatedQueryIdThis attribute is the system time in milli seconds that the object was last refreshed on -
invalidationState
protected int invalidationStateInvalidation State can be used to indicate whether this cache key is considered valid -
CHECK_INVALIDATION_POLICY
public static final int CHECK_INVALIDATION_POLICYThe following constants are used for the invalidationState variable- See Also:
-
CACHE_KEY_INVALID
public static final int CACHE_KEY_INVALID- See Also:
-
MAX_WAIT_TRIES
public static final int MAX_WAIT_TRIES- See Also:
-
readTime
protected long readTimeThe read time stores the millisecond value of the last time the object help by this cache key was confirmed as up to date. -
isWrapper
protected boolean isWrapperStores if this CacheKey instance is a wrapper for the underlying CacheKey. CacheKey wrappers may be used with cache interceptors. -
protectedForeignKeys
Stores retrieved FK values for relationships that are not stored in the Entity -
isIsolated
protected boolean isIsolatedSet to true if this CacheKey comes from an IsolatedClientSession, or DatabaseSessionImpl. -
transactionId
The ID of the database transaction that last wrote the object. This is used for database change notification.
-
-
Constructor Details
-
CacheKey
protected CacheKey()Internal: Only used by subclasses that may want to wrap the cache key. Could be replaced by switching to an interface. -
CacheKey
-
CacheKey
-
CacheKey
-
-
Method Details
-
acquire
public void acquire()Acquire the lock on the cache key object.- Overrides:
acquire
in classConcurrencyManager
-
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 classConcurrencyManager
-
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 classConcurrencyManager
-
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 -
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 classConcurrencyManager
-
acquireWithWait
public boolean acquireWithWait(boolean forMerge, int wait) 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:
acquireWithWait
in classConcurrencyManager
-
acquireDeferredLock
public void acquireDeferredLock()Acquire the deferred lock.- Overrides:
acquireDeferredLock
in classConcurrencyManager
-
acquireLock
-
checkReadLock
public void 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.- Overrides:
checkReadLock
in classConcurrencyManager
-
checkDeferredLock
public void 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.- Overrides:
checkDeferredLock
in classConcurrencyManager
-
acquireReadLock
public void acquireReadLock()Acquire the read lock on the cache key object.- Overrides:
acquireReadLock
in classConcurrencyManager
-
acquireReadLockNoWait
public boolean acquireReadLockNoWait()Acquire the read lock on the cache key object. Return true if acquired.- Overrides:
acquireReadLockNoWait
in classConcurrencyManager
-
clone
INTERNAL: Clones itself. -
equals
Determine if the receiver is equal to anObject. If anObject is a CacheKey, do further comparison, otherwise, return false. -
equals
Determine if the receiver is equal to key. Use an index compare, because it is much faster than enumerations. -
getLastUpdatedQueryId
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. -
getKey
-
getActiveThread
Return the active thread.- Overrides:
getActiveThread
in classConcurrencyManager
-
getObject
-
getOwningMap
-
getReadTime
public long getReadTime()INTERNAL: Return the current value of the Read Time variable -
getRecord
-
getWrapper
-
getWrappedCacheKey
If a Wrapper subclasses this CacheKey this method will be used to unwrap the cache key. -
getWriteLockValue
-
hashCode
public int hashCode()Overrides hashCode() in Object to use the primaryKey's hashCode for storage in data structures. -
hasProtectedForeignKeys
public boolean hasProtectedForeignKeys()Returns true if the protectedForeignKeys record is non-null and non-empty, false otherwise. -
isIsolated
public boolean isIsolated()Returns true if this CacheKey is from an IsolatedClientSession -
isWrapper
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. -
getProtectedForeignKeys
INTERNAL: Return the FK cache -
getInvalidationState
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. -
release
public void release()Release the lock on the cache key object.- Overrides:
release
in classConcurrencyManager
-
releaseDeferredLock
public void releaseDeferredLock()Release the deferred lock- Overrides:
releaseDeferredLock
in classConcurrencyManager
-
releaseReadLock
public void releaseReadLock()Release the read lock on the cache key object.- Overrides:
releaseReadLock
in classConcurrencyManager
-
removeFromOwningMap
Removes this cacheKey from the owning map -
setInvalidationState
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. -
setLastUpdatedQueryId
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. -
setKey
-
setObject
-
setOwningMap
-
setProtectedForeignKeys
-
setReadTime
public void setReadTime(long readTime) INTERNAL: Set the read time of this cache key -
setRecord
-
setWrapper
-
setWriteLockValue
-
toString
Description copied from class:ConcurrencyManager
Print the nested depth.- Overrides:
toString
in classConcurrencyManager
-
updateAccess
public void updateAccess()Notifies that cache key that it has been accessed. Allows the LRU sub-cache to be maintained. -
setIsolated
public void setIsolated(boolean isIsolated) -
setIsWrapper
public void setIsWrapper(boolean isWrapper) -
getTransactionId
-
setTransactionId
-
waitForObject
-