Module org.eclipse.persistence.core
Class FullIdentityMap
java.lang.Object
org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
org.eclipse.persistence.internal.identitymaps.FullIdentityMap
- All Implemented Interfaces:
Serializable
,Cloneable
,IdentityMap
- Direct Known Subclasses:
CacheIdentityMap
,UnitOfWorkIdentityMap
,WeakIdentityMap
Purpose: A FullIdentityMap holds all objects stored within it for the life of the application.
Responsibilities:
- Guarantees identity
- Holds all cached objects indefinitely.
- Since:
- TOPLink/Java 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionMap of CacheKeys stored using their key.Fields inherited from class org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
descriptor, isIsolated, maxSize, session
-
Constructor Summary
ConstructorsConstructorDescriptionUsed to allow subclasses to build different map type.FullIdentityMap
(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated) -
Method Summary
Modifier and TypeMethodDescriptionclone()
INTERNAL: Clones itself.Allow for theCacheKey
elements to be iterated.void
collectLocks
(HashMap threadList) INTERNAL: Used to print all the Locks in every identity map in this session.elements()
Allow for the cacheCacheKey.getObject()
elements to be iterated.getCacheKey
(Object searchKey, boolean forMerge) Return the cache key matching the primary key of the searchKey.Return the cache keys.int
getSize()
Return the number of CacheKeys in the IdentityMap.int
Return the number of actual objects of type myClass in the IdentityMap.keys()
Allow for the cache keys to be iterated on.keys
(boolean checkReadLocks) Allow for theCacheKey
elements to be iterated.void
lazyRelationshipLoaded
(Object object, ValueHolderInterface valueHolder, ForeignReferenceMapping mapping) Notify the cache that a lazy relationship has been triggered in the object and the cache may need to be updatedStore the object in the cache at its primary key.protected CacheKey
putCacheKeyIfAbsent
(CacheKey searchKey) Return the CacheKey (with object) matching the searchKey.Removes the CacheKey from the map.void
resetCacheKey
(CacheKey key, Object object, Object writeLockValue, long readTime) Reset the cache key with new data.protected void
setCacheKeys
(Map<Object, CacheKey> cacheKeys) Methods inherited from class org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
acquireDeferredLock, acquireLock, acquireLockNoWait, acquireLockWithWait, acquireReadLockOnCacheKey, acquireReadLockOnCacheKeyNoWait, containsKey, createCacheKey, get, getAllCacheKeysFromIdentityMapWithEntityPK, getAllFromIdentityMapWithEntityPK, getCacheKeyForLock, getCacheKeyWithReadLock, getDefaultIdentityMapClass, getDescriptor, getDescriptorClass, getMaxSize, getWrapper, getWriteLockValue, release, remove, setDescriptor, setMaxSize, setWrapper, setWriteLockValue, toString, updateMaxSize
-
Field Details
-
cacheKeys
Map of CacheKeys stored using their key.
-
-
Constructor Details
-
FullIdentityMap
public FullIdentityMap()Used to allow subclasses to build different map type. -
FullIdentityMap
public FullIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated)
-
-
Method Details
-
clone
INTERNAL: Clones itself.- Specified by:
clone
in interfaceIdentityMap
- Overrides:
clone
in classAbstractIdentityMap
-
collectLocks
INTERNAL: Used to print all the Locks in every identity map in this session.- Specified by:
collectLocks
in interfaceIdentityMap
- Specified by:
collectLocks
in classAbstractIdentityMap
-
elements
Allow for the cacheCacheKey.getObject()
elements to be iterated.- Specified by:
elements
in interfaceIdentityMap
- Specified by:
elements
in classAbstractIdentityMap
- Returns:
Enumeration
ofCacheKey.getObject()
instances.
-
getCacheKey
Return the cache key matching the primary key of the searchKey. If no object for the key exists, return null.- Specified by:
getCacheKey
in interfaceIdentityMap
- Specified by:
getCacheKey
in classAbstractIdentityMap
-
putCacheKeyIfAbsent
Return the CacheKey (with object) matching the searchKey. If the CacheKey is missing then put the searchKey in the map. The searchKey should have already been locked.- Specified by:
putCacheKeyIfAbsent
in classAbstractIdentityMap
-
getCacheKeys
Return the cache keys. -
getSize
public int getSize()Return the number of CacheKeys in the IdentityMap. This may contain weak referenced objects that have been garbage collected.- Specified by:
getSize
in interfaceIdentityMap
- Specified by:
getSize
in classAbstractIdentityMap
-
getSize
Return the number of actual objects of type myClass in the IdentityMap. Recurse = true will include subclasses of myClass in the count.- Specified by:
getSize
in interfaceIdentityMap
- Specified by:
getSize
in classAbstractIdentityMap
-
keys
Allow for the cache keys to be iterated on. Read locks will be checked.- Specified by:
keys
in interfaceIdentityMap
- Specified by:
keys
in classAbstractIdentityMap
-
keys
Allow for theCacheKey
elements to be iterated.CacheKey
Collection
is reused so this iteration may not be thread safe.- Parameters:
checkReadLocks
- value oftrue
if read lock on theCacheKey
instances should be checked orfalse
otherwise- Returns:
Enumeration
ofCacheKey
instances.
-
cloneKeys
Allow for theCacheKey
elements to be iterated. Clone ofCacheKey
Collection
is returned so this iteration should be thread safe.- Returns:
Enumeration
with clone of theCacheKey
Collection
-
lazyRelationshipLoaded
public void lazyRelationshipLoaded(Object object, ValueHolderInterface valueHolder, ForeignReferenceMapping mapping) Notify the cache that a lazy relationship has been triggered in the object and the cache may need to be updated -
put
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 interfaceIdentityMap
- Specified by:
put
in classAbstractIdentityMap
- 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.
-
remove
Removes the CacheKey from the map.- Specified by:
remove
in interfaceIdentityMap
- Specified by:
remove
in classAbstractIdentityMap
- Returns:
- the object held within the CacheKey or null if no object cached for given cacheKey.
-
resetCacheKey
Reset the cache key with new data. -
setCacheKeys
-