*/
private Cacheable addEntry(CachedItem item, Object key, boolean forCreate, Object createParameter)
throws StandardException {
Cacheable entry = null;
long origEntrySize = 0;
if( useByteCount)
origEntrySize = getItemSize( item);
try
{
if (SanityManager.DEBUG) {
if (SanityManager.DEBUG_ON(ClockFactory.CacheTrace))
{
SanityManager.DEBUG(ClockFactory.CacheTrace, name +
" item " + item + " take on identity " + key);
}
}
// tell the object it needs to create itself
entry = item.takeOnIdentity(this, holderFactory, key, forCreate, createParameter);
}
finally
{
boolean notifyWaiters;
synchronized (this) {
Object removed = cache_.remove(key);
if (SanityManager.DEBUG) {
SanityManager.ASSERT(removed == item);
}
if (entry != null) {
// put the actual key into the hash table, not the one that was passed in
// for the find or create. This is because the caller may re-use the key
// for another cache operation, which would corrupt our hashtable
cache_.put(entry.getIdentity(), item);
if( useByteCount)
currentByteCount += ((SizedCacheable) entry).getSize() - origEntrySize;
item.setValidState(true);
validItemCount++;
notifyWaiters = true;