Methods Summary |
---|
public java.lang.Object | clone()INTERNAL:
Clones itself.
FullIdentityMap clone = (FullIdentityMap)super.clone();
clone.setCacheKeys(new Hashtable(getCacheKeys().size()));
for (Enumeration cacheKeysEnum = getCacheKeys().elements();
cacheKeysEnum.hasMoreElements();) {
CacheKey key = (CacheKey)((CacheKey)cacheKeysEnum.nextElement()).clone();
clone.getCacheKeys().put(key, key);
}
return clone;
|
public void | collectLocks(java.util.HashMap threadList)INTERNAL:
Used to print all the Locks in every identity map in this session.
The output of this method will go to log passed in as a parameter.
Iterator cacheKeyIterator = this.cacheKeys.values().iterator();
while (cacheKeyIterator.hasNext()) {
CacheKey cacheKey = (CacheKey)cacheKeyIterator.next();
if (cacheKey.isAcquired()) {
Thread activeThread = cacheKey.getMutex().getActiveThread();
Set set = (Set)threadList.get(activeThread);
if (set == null) {
set = new HashSet();
threadList.put(activeThread, set);
}
set.add(cacheKey);
}
}
|
public java.util.Enumeration | elements()Allow for the cache to be iterated on.
return new IdentityMapEnumeration(this);
|
protected synchronized oracle.toplink.essentials.internal.identitymaps.CacheKey | getCacheKey(oracle.toplink.essentials.internal.identitymaps.CacheKey searchKey)Return the object indexed in the recevier at the cache key.
If now object for the key exists, return null.
return (CacheKey)getCacheKeys().get(searchKey);
|
public java.util.Hashtable | getCacheKeys()
return cacheKeys;
|
public int | getSize()Return the number of objects in the IdentityMap.
return cacheKeys.size();
|
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.
int i = 0;
Enumeration keys = getCacheKeys().keys();
while (keys.hasMoreElements()) {
CacheKey key = (CacheKey)keys.nextElement();
Object obj = key.getObject();
if (obj != null) {
if (recurse && myClass.isInstance(obj)) {
i++;
} else if (obj.getClass().equals(myClass)) {
i++;
}
}
}
return i;
|
public java.util.Enumeration | keys()Allow for the cache keys to be iterated on.
return new IdentityMapKeyEnumeration(this);
|
public oracle.toplink.essentials.internal.identitymaps.CacheKey | put(java.util.Vector primaryKey, java.lang.Object object, java.lang.Object writeLockValue, long readTime)Store the object in the cache at its primary key.
CacheKey cacheKey = getCacheKey(primaryKey);
// Find the cache key in the hashtable, reset it.
if (cacheKey != null) {
// The cache key has to be locked during the re-setting, keep other threads from accessing the object.
resetCacheKey(cacheKey, object, writeLockValue);
// Still must put the object to ensure the LRU caching.
put(cacheKey);
} else {
// Cache key not found, create a new one and put it into the hashtable.
cacheKey = createCacheKey(primaryKey, object, writeLockValue, readTime);
put(cacheKey);
}
return cacheKey;
|
protected void | put(oracle.toplink.essentials.internal.identitymaps.CacheKey cacheKey)Store the object in the cache with the cache key.
//synchronized because subclasses may not sync around call
synchronized(this){
getCacheKeys().put(cacheKey, cacheKey);
}
cacheKey.setOwningMap(this);
|
public java.lang.Object | remove(oracle.toplink.essentials.internal.identitymaps.CacheKey cacheKey)Removes the CacheKey from the Hashtable.
if (cacheKey != null) {
//Cache key needs to be locked when removing from the Hashtable
cacheKey.acquire();
//remove opration from the hashtable has to be synchronized
synchronized (this) {
getCacheKeys().remove(cacheKey);
}
//Cache key needs to be released after removing from the Hashtable
cacheKey.release();
} else {
return null;
}
return cacheKey.getObject();
|
public void | resetCacheKey(oracle.toplink.essentials.internal.identitymaps.CacheKey key, java.lang.Object object, java.lang.Object writeLockValue)
resetCacheKey(key, object, writeLockValue, 0);
|
public void | resetCacheKey(oracle.toplink.essentials.internal.identitymaps.CacheKey key, java.lang.Object object, java.lang.Object writeLockValue, long readTime)
key.acquire();
key.setObject(object);
key.setWriteLockValue(writeLockValue);
key.setReadTime(readTime);
key.release();
|
protected void | setCacheKeys(java.util.Hashtable cacheKeys)
this.cacheKeys = cacheKeys;
|