com.googlecode.ehcache.annotations
Class DefaultCacheableInterceptor

java.lang.Object
  extended by com.googlecode.ehcache.annotations.DefaultCacheableInterceptor
All Implemented Interfaces:
CacheableInterceptor

public class DefaultCacheableInterceptor
extends java.lang.Object
implements CacheableInterceptor

Default interceptor that always returns cached values, throws cached exceptions and always caches values and exceptions.

Version:
$Revision: 656 $
Author:
Eric Dalquist

Field Summary
static DefaultCacheableInterceptor INSTANCE
           
 
Constructor Summary
DefaultCacheableInterceptor()
           
 
Method Summary
 boolean postInvokeCacheable(net.sf.ehcache.Ehcache cache, org.aopalliance.intercept.MethodInvocation methodInvocation, java.io.Serializable key, java.lang.Object value)
          Called after a method invocation but before the returned value is cached Not used when Cacheable.selfPopulating() is set to true.
 boolean postInvokeCacheableException(net.sf.ehcache.Ehcache exceptionCache, org.aopalliance.intercept.MethodInvocation methodInvocation, java.io.Serializable key, java.lang.Throwable t)
          Called after a method invocation throws an exception AND an exception cache is configured for the interceptor but before the exception is cached
 boolean preInvokeCachable(net.sf.ehcache.Ehcache cache, org.aopalliance.intercept.MethodInvocation methodInvocation, java.io.Serializable key, java.lang.Object value)
          Called after a cache hit but before the method invocation.
 boolean preInvokeCacheableException(net.sf.ehcache.Ehcache exceptionCache, org.aopalliance.intercept.MethodInvocation methodInvocation, java.io.Serializable key, java.lang.Throwable t)
          Called after the cache lookup but before the method invocation if a cached exception was found
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final DefaultCacheableInterceptor INSTANCE
Constructor Detail

DefaultCacheableInterceptor

public DefaultCacheableInterceptor()
Method Detail

preInvokeCachable

public boolean preInvokeCachable(net.sf.ehcache.Ehcache cache,
                                 org.aopalliance.intercept.MethodInvocation methodInvocation,
                                 java.io.Serializable key,
                                 java.lang.Object value)
Description copied from interface: CacheableInterceptor
Called after a cache hit but before the method invocation. Not used when Cacheable.selfPopulating() is set to true.

Specified by:
preInvokeCachable in interface CacheableInterceptor
Parameters:
cache - The cache used for this invocation
methodInvocation - The method invocation that has been intercepted
key - The generated cache key
value - The found cache value if any, may be null
Returns:
true if the intercepted method invocation should be invoked, false if it should not be invoked and the value should be returned.

postInvokeCacheable

public boolean postInvokeCacheable(net.sf.ehcache.Ehcache cache,
                                   org.aopalliance.intercept.MethodInvocation methodInvocation,
                                   java.io.Serializable key,
                                   java.lang.Object value)
Description copied from interface: CacheableInterceptor
Called after a method invocation but before the returned value is cached Not used when Cacheable.selfPopulating() is set to true.

Specified by:
postInvokeCacheable in interface CacheableInterceptor
Parameters:
cache - The cache used for this invocation
methodInvocation - The method invocation that has been intercepted
key - The generated cache key
value - The value returned by the invocation
Returns:
true if the value should be cached, false if not

preInvokeCacheableException

public boolean preInvokeCacheableException(net.sf.ehcache.Ehcache exceptionCache,
                                           org.aopalliance.intercept.MethodInvocation methodInvocation,
                                           java.io.Serializable key,
                                           java.lang.Throwable t)
Description copied from interface: CacheableInterceptor
Called after the cache lookup but before the method invocation if a cached exception was found

Specified by:
preInvokeCacheableException in interface CacheableInterceptor
Parameters:
exceptionCache - The cache used for this invocation
methodInvocation - The method invocation that has been intercepted
key - The generated cache key
t - The exception thrown by the invocation
Returns:
true if the intercepted method invocation should be invoked, false if it should not be invoked and the cached exception thrown.

postInvokeCacheableException

public boolean postInvokeCacheableException(net.sf.ehcache.Ehcache exceptionCache,
                                            org.aopalliance.intercept.MethodInvocation methodInvocation,
                                            java.io.Serializable key,
                                            java.lang.Throwable t)
Description copied from interface: CacheableInterceptor
Called after a method invocation throws an exception AND an exception cache is configured for the interceptor but before the exception is cached

Specified by:
postInvokeCacheableException in interface CacheableInterceptor
Parameters:
exceptionCache - The cache used for this invocation
methodInvocation - The method invocation that has been intercepted
key - The generated cache key
t - The exception thrown by the invocation
Returns:
true if the exception should be cached, false if not


Copyright © 2011. All Rights Reserved.