Search in sources :

Example 6 with CacheManager

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);
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) ServletContext(javax.servlet.ServletContext) CacheManager(com.sun.appserv.web.cache.CacheManager) Cache(com.sun.appserv.util.cache.Cache)

Aggregations

CacheManager (com.sun.appserv.web.cache.CacheManager)6 ServletContext (javax.servlet.ServletContext)5 Cache (com.sun.appserv.util.cache.Cache)3 CacheMapping (com.sun.appserv.web.cache.mapping.CacheMapping)1 ValueConstraint (com.sun.appserv.web.cache.mapping.ValueConstraint)1 SunWebApp (com.sun.enterprise.deployment.runtime.web.SunWebApp)1 HashMap (java.util.HashMap)1 NamingException (javax.naming.NamingException)1 DispatcherType (javax.servlet.DispatcherType)1 ServletRequest (javax.servlet.ServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 FilterDef (org.apache.catalina.deploy.FilterDef)1 FilterMap (org.apache.catalina.deploy.FilterMap)1 org.glassfish.web.deployment.runtime (org.glassfish.web.deployment.runtime)1