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;
}
Aggregations