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 theCacheKeyelements to be iterated.voidcollectLocks(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.intgetSize()Return the number of CacheKeys in the IdentityMap.intReturn 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 theCacheKeyelements to be iterated.voidlazyRelationshipLoaded(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 CacheKeyputCacheKeyIfAbsent(CacheKey searchKey) Return the CacheKey (with object) matching the searchKey.Removes the CacheKey from the map.voidresetCacheKey(CacheKey key, Object object, Object writeLockValue, long readTime) Reset the cache key with new data.protected voidsetCacheKeys(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:
clonein interfaceIdentityMap- Overrides:
clonein classAbstractIdentityMap
-
collectLocks
INTERNAL: Used to print all the Locks in every identity map in this session.- Specified by:
collectLocksin interfaceIdentityMap- Specified by:
collectLocksin classAbstractIdentityMap
-
elements
Allow for the cacheCacheKey.getObject()elements to be iterated.- Specified by:
elementsin interfaceIdentityMap- Specified by:
elementsin classAbstractIdentityMap- Returns:
EnumerationofCacheKey.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:
getCacheKeyin interfaceIdentityMap- Specified by:
getCacheKeyin 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:
putCacheKeyIfAbsentin 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:
getSizein interfaceIdentityMap- Specified by:
getSizein 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:
getSizein interfaceIdentityMap- Specified by:
getSizein classAbstractIdentityMap
-
keys
Allow for the cache keys to be iterated on. Read locks will be checked.- Specified by:
keysin interfaceIdentityMap- Specified by:
keysin classAbstractIdentityMap
-
keys
Allow for theCacheKeyelements to be iterated.CacheKeyCollectionis reused so this iteration may not be thread safe.- Parameters:
checkReadLocks- value oftrueif read lock on theCacheKeyinstances should be checked orfalseotherwise- Returns:
EnumerationofCacheKeyinstances.
-
cloneKeys
Allow for theCacheKeyelements to be iterated. Clone ofCacheKeyCollectionis returned so this iteration should be thread safe.- Returns:
Enumerationwith clone of theCacheKeyCollection
-
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:
putin interfaceIdentityMap- Specified by:
putin 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:
removein interfaceIdentityMap- Specified by:
removein 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
-