* @return The first {@link HttpCache} annotation found. If none is found then null.
*/
protected HttpCache getAnnotation(Method method, Class<? extends ActionBean> beanClass) {
// check cache first
final CacheKey cacheKey = new CacheKey(method, beanClass);
HttpCache annotation = cache.get(cacheKey);
if (annotation != null) {
return annotation == NULL_CACHE ? null : annotation;
}
// not found in cache so figure it out
annotation = method.getAnnotation(HttpCache.class);
if (annotation == null) {
// search the method's class and its superclasses
Class<?> clazz = beanClass;
do {
annotation = clazz.getAnnotation(HttpCache.class);
clazz = clazz.getSuperclass();
} while (clazz != null && annotation == null);
}
// check for weirdness
if (annotation != null) {
logger.debug("Found ", HttpCache.class.getSimpleName(), " for ", beanClass.getName(),
".", method.getName(), "()");
final int expires = annotation.expires();
if (annotation.allow() && expires != HttpCache.DEFAULT_EXPIRES && expires < 0) {
logger.warn(HttpCache.class.getSimpleName(), " for ", beanClass.getName(), ".",
method.getName(), "() allows caching but expires in the past");
}
else if (!annotation.allow() && expires != HttpCache.DEFAULT_EXPIRES) {
logger.warn(HttpCache.class.getSimpleName(), " for ", beanClass.getName(), ".",
method.getName(), "() disables caching but explicitly sets expires");
}
}
else {