FileDocCategorySizeDatePackage
NRUSessionCache.javaAPI DocGlassfish v2 API3920Fri May 04 22:33:00 BST 2007com.sun.ejb.containers.util.cache

NRUSessionCache

public class NRUSessionCache extends LruSessionCache

Fields Summary
protected boolean
doOrdering
protected int
orderingThreshold
Constructors Summary
public NRUSessionCache(String cacheName, com.sun.ejb.spi.container.SFSBContainerCallback container, int cacheIdleTime, int removalTime)


       
             
    
        super("NRU-" + cacheName, container, cacheIdleTime, removalTime);
    
Methods Summary
public voidinit(int maxEntries, float loadFactor, java.util.Properties props)

        super.init(maxEntries, loadFactor, props);
        orderingThreshold = (int) (0.75 * threshold);
    
protected voiditemAccessed(CacheItem item)

        LruCacheItem lc = (LruCacheItem) item;
        synchronized (this) {
            if (lc.isTrimmed) {
                lc.isTrimmed = false;
                CacheItem overflow = super.itemAdded(item);
                if (overflow != null) {
                    trimItem(overflow);
                }
            } else if (doOrdering) {
                super.itemAccessed(item);
            }
        }
    
protected CacheItemitemAdded(CacheItem item)

        CacheItem addedItem = super.itemAdded(item);
        doOrdering = (entryCount >= orderingThreshold);
        return addedItem;
    
protected voiditemRefreshed(CacheItem item, int oldSize)

    
protected voiditemRemoved(CacheItem item)

        super.itemRemoved(item);
        doOrdering = (entryCount >= orderingThreshold);
    
public voidtrimTimedoutItems(int maxCount)

        // If we are maintaining an ordered list use 
        // the superclass method for trimming
        if (doOrdering) {
            super.trimTimedoutItems(maxCount);
        } else {
            // we don't have an ordered list, 
            // so go through the whole cache and pick victims
            trimUnSortedTimedoutItems(maxCount);
        }