Class FullIdentityMap
- java.lang.Object
-
- org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
-
- org.eclipse.persistence.internal.identitymaps.FullIdentityMap
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,IdentityMap
- Direct Known Subclasses:
CacheIdentityMap,UnitOfWorkIdentityMap,WeakIdentityMap
public class FullIdentityMap extends AbstractIdentityMap
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Object,CacheKey>cacheKeysMap of CacheKeys stored using their key.-
Fields inherited from class org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
descriptor, isIsolated, maxSize, session
-
-
Constructor Summary
Constructors Constructor Description FullIdentityMap()Used to allow subclasses to build different map type.FullIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()INTERNAL: Clones itself.java.util.Enumeration<CacheKey>cloneKeys()Allow for theCacheKeyelements to be iterated.voidcollectLocks(java.util.HashMap threadList)INTERNAL: Used to print all the Locks in every identity map in this session.java.util.Enumerationelements()Allow for the cacheCacheKey.getObject()elements to be iterated.CacheKeygetCacheKey(java.lang.Object searchKey, boolean forMerge)Return the cache key matching the primary key of the searchKey.java.util.Map<java.lang.Object,CacheKey>getCacheKeys()Return the cache keys.intgetSize()Return the number of CacheKeys in the IdentityMap.intgetSize(java.lang.Class myClass, boolean recurse)Return the number of actual objects of type myClass in the IdentityMap.java.util.Enumeration<CacheKey>keys()Allow for the cache keys to be iterated on.java.util.Enumeration<CacheKey>keys(boolean checkReadLocks)Allow for theCacheKeyelements to be iterated.voidlazyRelationshipLoaded(java.lang.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 updatedCacheKeyput(java.lang.Object primaryKey, java.lang.Object object, java.lang.Object writeLockValue, long readTime)Store the object in the cache at its primary key.protected CacheKeyputCacheKeyIfAbsent(CacheKey searchKey)Return the CacheKey (with object) matching the searchKey.java.lang.Objectremove(CacheKey cacheKey)Removes the CacheKey from the map.voidresetCacheKey(CacheKey key, java.lang.Object object, java.lang.Object writeLockValue, long readTime)Reset the cache key with new data.protected voidsetCacheKeys(java.util.Map<java.lang.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 Detail
-
cacheKeys
protected java.util.Map<java.lang.Object,CacheKey> cacheKeys
Map of CacheKeys stored using their key.
-
-
Constructor Detail
-
FullIdentityMap
public FullIdentityMap()
Used to allow subclasses to build different map type.
-
FullIdentityMap
public FullIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated)
-
-
Method Detail
-
clone
public java.lang.Object clone()
INTERNAL: Clones itself.- Specified by:
clonein interfaceIdentityMap- Overrides:
clonein classAbstractIdentityMap
-
collectLocks
public void collectLocks(java.util.HashMap threadList)
INTERNAL: Used to print all the Locks in every identity map in this session.- Specified by:
collectLocksin interfaceIdentityMap- Specified by:
collectLocksin classAbstractIdentityMap
-
elements
public java.util.Enumeration elements()
Allow for the cacheCacheKey.getObject()elements to be iterated.- Specified by:
elementsin interfaceIdentityMap- Specified by:
elementsin classAbstractIdentityMap- Returns:
EnumerationofCacheKey.getObject()instances.
-
getCacheKey
public CacheKey getCacheKey(java.lang.Object searchKey, boolean forMerge)
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
protected CacheKey putCacheKeyIfAbsent(CacheKey searchKey)
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
public java.util.Map<java.lang.Object,CacheKey> 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
public int getSize(java.lang.Class myClass, boolean recurse)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
public java.util.Enumeration<CacheKey> keys()
Allow for the cache keys to be iterated on. Read locks will be checked.- Specified by:
keysin interfaceIdentityMap- Specified by:
keysin classAbstractIdentityMap
-
keys
public java.util.Enumeration<CacheKey> keys(boolean checkReadLocks)
-
cloneKeys
public java.util.Enumeration<CacheKey> 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(java.lang.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
public CacheKey put(java.lang.Object primaryKey, java.lang.Object object, java.lang.Object writeLockValue, long readTime)
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
public java.lang.Object remove(CacheKey cacheKey)
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
public void resetCacheKey(CacheKey key, java.lang.Object object, java.lang.Object writeLockValue, long readTime)
Reset the cache key with new data.
-
setCacheKeys
protected void setCacheKeys(java.util.Map<java.lang.Object,CacheKey> cacheKeys)
-
-