Search in sources :

Example 6 with CacheMapping

use of com.sun.appserv.web.cache.mapping.CacheMapping in project Payara by payara.

the class DefaultCacheHelper method getTimeout.

/**
 * get timeout for the cacheable data in this request
 *  @param request incoming <code>HttpServletRequest</code> object
 *  @return either the statically specified value or from the request
 *  fields. If not specified, get the timeout defined for the
 *  cache element.
 */
public int getTimeout(HttpServletRequest request) {
    // cache mapping associated with the request
    CacheMapping mapping = lookupCacheMapping(request);
    // get the statically configured value, if any
    int result = mapping.getTimeout();
    // if the field is not defined, return the configured value
    Field field = mapping.getTimeoutField();
    if (field != null) {
        Object value = field.getValue(context, request);
        if (value != null) {
            try {
                // Integer type timeout object
                Integer timeoutAttr = Integer.valueOf(value.toString());
                result = timeoutAttr.intValue();
            } catch (NumberFormatException cce) {
            }
        }
    }
    // Note: this could be CacheHelper.TIMEOUT_NOT_SET
    return result;
}
Also used : Field(com.sun.appserv.web.cache.mapping.Field) ConstraintField(com.sun.appserv.web.cache.mapping.ConstraintField) CacheMapping(com.sun.appserv.web.cache.mapping.CacheMapping)

Aggregations

CacheMapping (com.sun.appserv.web.cache.mapping.CacheMapping)6 ConstraintField (com.sun.appserv.web.cache.mapping.ConstraintField)4 Field (com.sun.appserv.web.cache.mapping.Field)3 CacheManager (com.sun.appserv.web.cache.CacheManager)1 ValueConstraint (com.sun.appserv.web.cache.mapping.ValueConstraint)1 String (java.lang.String)1 HashMap (java.util.HashMap)1 DispatcherType (javax.servlet.DispatcherType)1 LifecycleException (org.apache.catalina.LifecycleException)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