use of com.sun.appserv.util.cache.Cache in project Payara by payara.
the class CacheContextListener method contextDestroyed.
/**
* 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();
}
}
use of com.sun.appserv.util.cache.Cache in project Payara by payara.
the class CacheSessionListener method sessionCreated.
/**
* Receives notification that a session was created, and adds newly
* created cache for JSP tag body invocations as a session attribute.
*
* @param hse the notification event
*/
public void sessionCreated(HttpSessionEvent hse) {
HttpSession session = hse.getSession();
ServletContext context = session.getServletContext();
// Check if a cache manager has already been created and set in the
// context
CacheManager cm = (CacheManager) context.getAttribute(CacheManager.CACHE_MANAGER_ATTR_NAME);
// to create a new cache
if (cm == null) {
cm = new CacheManager();
}
Cache cache = null;
try {
cache = cm.createCache();
} catch (Exception ex) {
}
// Set the cache as a session attribute
if (cache != null) {
session.setAttribute(Constants.JSPTAG_CACHE_KEY, cache);
}
}
use of com.sun.appserv.util.cache.Cache in project Payara by payara.
the class FlushTag method doStartTag.
// ---------------------------------------------------------------------
// Tag logic
/**
* 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);
if (_key != null) {
String key = CacheUtil.generateKey(_key, pageContext);
// remove the entry for the key
cache.remove(key);
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, LogFacade.FLUSH_TAG_CLEAR_KEY, key);
} else {
// clear the entire cache
cache.clear();
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, LogFacade.FLUSH_TAG_CLEAR_CACHE);
}
return SKIP_BODY;
}
Aggregations