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
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 Map<Object,CacheKey>
cacheKeys
Map 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 Object
clone()
INTERNAL: Clones itself.Enumeration<CacheKey>
cloneKeys()
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.Enumeration
elements()
Allow for the cacheCacheKey.getObject()
elements to be iterated.CacheKey
getCacheKey(Object searchKey, boolean forMerge)
Return the cache key matching the primary key of the searchKey.Map<Object,CacheKey>
getCacheKeys()
Return the cache keys.int
getSize()
Return the number of CacheKeys in the IdentityMap.int
getSize(Class myClass, boolean recurse)
Return the number of actual objects of type myClass in the IdentityMap.Enumeration<CacheKey>
keys()
Allow for the cache keys to be iterated on.Enumeration<CacheKey>
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 updatedCacheKey
put(Object primaryKey, Object object, Object writeLockValue, long readTime)
Store the object in the cache at its primary key.protected CacheKey
putCacheKeyIfAbsent(CacheKey searchKey)
Return the CacheKey (with object) matching the searchKey.Object
remove(CacheKey cacheKey)
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
-
-
-
-
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 Object clone()
INTERNAL: Clones itself.- Specified by:
clone
in interfaceIdentityMap
- Overrides:
clone
in classAbstractIdentityMap
-
collectLocks
public void collectLocks(HashMap threadList)
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
public Enumeration 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
public CacheKey getCacheKey(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:
getCacheKey
in interfaceIdentityMap
- Specified by:
getCacheKey
in 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:
putCacheKeyIfAbsent
in classAbstractIdentityMap
-
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
public int getSize(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:
getSize
in interfaceIdentityMap
- Specified by:
getSize
in classAbstractIdentityMap
-
keys
public Enumeration<CacheKey> 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
public Enumeration<CacheKey> keys(boolean checkReadLocks)
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
public Enumeration<CacheKey> 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
public CacheKey put(Object primaryKey, Object object, 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:
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
public Object remove(CacheKey cacheKey)
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
public void resetCacheKey(CacheKey key, Object object, Object writeLockValue, long readTime)
Reset the cache key with new data.
-
-