use of com.sun.appserv.web.cache.CacheManager 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);
}
}
Aggregations