public void run() { try { cache.trimTimedoutItems(Integer.MAX_VALUE); } catch (Exception ex) { if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "ejb.sfsb_helper_remove_idle_beans_failed", ex); } } }
private void buildCache() { String cacheName = ejbDescriptor.getEjbClassName(); String victimPolicy = cacheProps.getVictimSelectionPolicy(); if (cacheProps.getMaxCacheSize() <= 0) { sessionCache = new UnBoundedSessionCache( cacheName, sfsbContainer, cacheProps.getCacheIdleTimeoutInSeconds(), cacheProps.getRemovalTimeoutInSeconds()); } else if ("lru".equalsIgnoreCase(victimPolicy)) { sessionCache = new LruSessionCache( cacheName, sfsbContainer, cacheProps.getCacheIdleTimeoutInSeconds(), cacheProps.getRemovalTimeoutInSeconds()); } else if ("fifo".equalsIgnoreCase(victimPolicy)) { sessionCache = new FIFOSessionCache( cacheName, sfsbContainer, cacheProps.getCacheIdleTimeoutInSeconds(), cacheProps.getRemovalTimeoutInSeconds()); } else { sessionCache = new NRUSessionCache( cacheName, sfsbContainer, cacheProps.getCacheIdleTimeoutInSeconds(), cacheProps.getRemovalTimeoutInSeconds()); } float ratio = (float) (1.0 * cacheProps.getNumberOfVictimsToSelect() / cacheProps.getMaxCacheSize()); float loadFactor = (float) (1.0 - ratio); if (loadFactor < 0 || loadFactor > 1) { loadFactor = 0.75f; } if (cacheProps.getMaxCacheSize() <= 0) { sessionCache.init(16 * 1024, loadFactor, null); } else { sessionCache.init(cacheProps.getMaxCacheSize(), loadFactor, null); } sessionCache.addCacheListener((CacheListener) sfsbContainer); sessionCache.setSessionStore(this.sfsbStoreManager); sfsbContainer.setSessionCache(sessionCache); if (cacheProps.getNumberOfVictimsToSelect() > sfsbContainer.MIN_PASSIVATION_BATCH_COUNT) { sfsbContainer.setPassivationBatchCount(cacheProps.getNumberOfVictimsToSelect()); } if (_logger.isLoggable(TRACE_LEVEL)) { _logger.log( TRACE_LEVEL, "Created cache [for " + ejbDescriptor.getName() + "] " + cacheProps + "; loadFactor: " + loadFactor + "; storeManager: " + this.sfsbStoreManager); } }