Top Description Fields Constructors Methods
org.eclipse.persistence.internal.identitymaps

public Class WeakIdentityMap

extends FullIdentityMap
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.internal.identitymaps.HardCacheWeakIdentityMap, org.eclipse.persistence.internal.identitymaps.SoftIdentityMap
Imports
java.util.*, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.internal.sessions.AbstractSession

Purpose: A WeakIdentityMap holds all objects referenced by the application only. The weak identity map is similar to the full identity map except for the fact that it allows full garbage collection.

Responsibilities:

Since
TOPLink/Java 1.0

Field Summary

Modifier and TypeField and Description
protected volatile int
cleanupCount

Keep track of a counter to amortize cleanup of dead cache keys

protected volatile int
cleanupSize

PERF: Keep track of a cleanup size to avoid cleanup bottleneck for large caches.

Inherited from org.eclipse.persistence.internal.identitymaps.FullIdentityMap:
cacheKeys

Constructor Summary

AccessConstructor and Description
public
WeakIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated)

Method Summary

Modifier and TypeMethod and Description
protected void
checkCleanup()

Check if garbage collected cache keys need to be cleaned up.

protected void
cleanupDeadCacheKeys()

Search for any cache keys that have been garbage collected and remove them.

public CacheKey
createCacheKey(Object primaryKey, Object object, Object writeLockValue, long readTime)

Overrides org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.createCacheKey.

Create the correct type of CacheKey for this map.
protected CacheKey
Inherited from org.eclipse.persistence.internal.identitymaps.FullIdentityMap:
clonecloneKeyscollectLockselementsgetCacheKeygetCacheKeysgetSizegetSizekeyskeyslazyRelationshipLoadedputremoveresetCacheKeysetCacheKeys

Field Detail

cleanupCountback to summary
protected volatile int cleanupCount

Keep track of a counter to amortize cleanup of dead cache keys

cleanupSizeback to summary
protected volatile int cleanupSize

PERF: Keep track of a cleanup size to avoid cleanup bottleneck for large caches.

Constructor Detail

WeakIdentityMapback to summary
public WeakIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated)

Method Detail

checkCleanupback to summary
protected void checkCleanup()

Check if garbage collected cache keys need to be cleaned up.

cleanupDeadCacheKeysback to summary
protected void cleanupDeadCacheKeys()

Search for any cache keys that have been garbage collected and remove them. This must be done because although the objects held by the cache keys will garbage collect, the keys themselves will not and must be cleaned up. This is a linear operation so is amortized through the cleanupCount to occur only once per cycle averaging to make the total time still constant.

createCacheKeyback to summary
public CacheKey createCacheKey(Object primaryKey, Object object, Object writeLockValue, long readTime)

Overrides org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.createCacheKey.

Doc from org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.createCacheKey.

Create the correct type of CacheKey for this map.

Annotations
@Override
putCacheKeyIfAbsentback to summary
protected CacheKey putCacheKeyIfAbsent(CacheKey searchKey)

Overrides org.eclipse.persistence.internal.identitymaps.FullIdentityMap.putCacheKeyIfAbsent.

Need to check for cleanup on put.

Annotations
@Override