/** * 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(); } } }
/** * 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(); } } }
/** * 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; }