public void componentDestroyed(Object instance, ComponentInvocation inv) { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "TM: componentDestroyed" + instance); _logger.log(Level.FINE, "TM: resourceTable before: " + resourceTable.getEntryCount()); } // Access resourceTable directly to avoid adding an empty list then removing it List l = (List)resourceTable.remove(getResourceTableKey(instance, inv)); processResourceList(l); if (_logger.isLoggable(Level.FINE)) _logger.log(Level.FINE, "TM: resourceTable after: " + resourceTable.getEntryCount()); }
/** * create the designated cache object * @return the Cache implementation * @throws Exception */ public Cache createCache(int cacacity, String className) throws Exception { // use the context class loader to load class so that any // user-defined classes in WEB-INF can also be loaded. ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class cacheClass = cl.loadClass(className); Cache cacheImpl = (Cache)cacheClass.newInstance(); cacheImpl.init(maxEntries, cacheProps); return cacheImpl; }
/** * This is called when the context is shutdown. */ public void contextDestroyed(ServletContextEvent sce) { ServletContext context = sce.getServletContext(); // Remove the cache from context and clear the cache Cache cache = (Cache)context.getAttribute(Constants.JSPTAG_CACHE_KEY); if (cache != null) { context.removeAttribute(Constants.JSPTAG_CACHE_KEY); cache.clear(); } } }
protected void destroyReadyStoreOnUndeploy() { if (readyStore == null) { return; } // destroy all EJB instances in readyStore synchronized ( readyStore ) { Iterator beans = readyStore.values(); while ( beans.hasNext() ) { EJBContextImpl ctx = (EJBContextImpl)beans.next(); transactionManager.componentDestroyed(ctx); } } readyStore.destroy(); readyStore = null; }
int index = cache.getIndex(key); do { entry = (HttpCacheEntry) cache.get(key); waitForRefresh = cache.waitRefresh(index); oldEntry = (HttpCacheEntry)cache.put(key, entry, entry.getSize()); cache.notifyRefresh(index); needNotify = false; oldEntry = (HttpCacheEntry)cache.remove(key); cache.notifyRefresh(index);
/** * doStartTag is called when the flush tag is encountered. By * the time this is called, the tag attributes are already set. * * @throws JspException the standard exception thrown * @return SKIP_BODY since the tag should be empty */ public int doStartTag() throws JspException { // get the cache from the specified scope Cache cache = CacheUtil.getCache(pageContext, _scope); // generate the cache key using the user specified key. if (_key != null) { String key = CacheUtil.generateKey(_key, pageContext); // remove the entry for the key cache.remove(key); if (_logger.isLoggable(Level.FINE)) _logger.fine("FlushTag: clear ["+ key +"]"); } else { // clear the entire cache cache.clear(); if (_logger.isLoggable(Level.FINE)) _logger.fine("FlushTag: clear cache"); } return SKIP_BODY; }
protected void removeContextFromReadyStore(Object primaryKey, EntityContextImpl context) { readyStore.remove(primaryKey, context); }
protected void createReadyStore(int cacheSize, int numberOfVictimsToSelect, float loadFactor, long idleTimeout) throws Exception { idleTimeout = (idleTimeout <= 0) ? -1 : idleTimeout; if (cacheSize <= 0 && idleTimeout <= 0) { readyStore = new BaseCache(); cacheSize = DEFAULT_CACHE_SIZE; readyStore.init(cacheSize, loadFactor, null); } else { cacheSize = (cacheSize <= 0) ? DEFAULT_CACHE_SIZE : cacheSize; LruCache lru = new LruCache(DEFAULT_CACHE_SIZE); if (numberOfVictimsToSelect >= 0) { loadFactor = (float) (1.0 - (1.0 * numberOfVictimsToSelect/cacheSize)); } lru.init(cacheSize, idleTimeout, loadFactor, null); readyStore = lru; readyStore.addCacheListener(this); } if (idleTimeout > 0) { idleBeansPassivator = setupIdleBeansPassivator(readyStore); } }
Object key = getResourceTableKey(instance, inv); if (key != null) l = (List) resourceTable.get(key);
public long getReadyCount() { return (readyStore == null) ? 0 : readyStore.getEntryCount(); }
_cache.put(_key, entry);
protected void addReadyEJB(EntityContextImpl context) { // add to the cache (can have multiple instances of beans per key) Object primaryKey = context.getPrimaryKey(); context.setState(BeanState.READY); readyStore.add(primaryKey, context); }
protected EntityContextImpl getReadyEJB(EjbInvocation inv) { Object primaryKey = inv.ejbObject.getKey(); EntityContextImpl context = null; // Try and get an EJB instance for this primaryKey from the // readyStore context = (EntityContextImpl)readyStore.remove(primaryKey); if (context == null || context.getState() != BeanState.READY) { context = activateEJBFromPool(primaryKey, inv); } return context; } //getReadyEJB(inv)
CacheEntry entry = (CacheEntry)_cache.get(_key);
/** * Receives notification that a session is about to be invalidated, and * clears the session's cache of JSP tag body invocations (if present). * * @param hse the notification event */ public void sessionDestroyed(HttpSessionEvent hse) { // Clear the cache HttpSession session = hse.getSession(); Cache cache = (Cache)session.getAttribute(Constants.JSPTAG_CACHE_KEY); if (cache != null) { cache.clear(); } } }
/** * Receives notification that the request is about to go out of scope * of the web application, and clears the request's cache of JSP tag * body invocations (if present). * * @param sre the notification event */ public void requestDestroyed(ServletRequestEvent sre) { // Clear the cache ServletRequest req = sre.getServletRequest(); Cache cache = (Cache) req.getAttribute(Constants.JSPTAG_CACHE_KEY); if (cache != null) { cache.clear(); } } }