com.googlecode.ehcache.annotations.interceptor
Class EhCacheInterceptor

java.lang.Object
  extended by com.googlecode.ehcache.annotations.interceptor.EhCacheInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor

public class EhCacheInterceptor
extends java.lang.Object
implements org.aopalliance.intercept.MethodInterceptor

Intercepter that handles invocations on methods annotated with Cacheable or TriggersRemove.

Version:
$Revision: 681 $
Author:
Eric Dalquist

Field Summary
protected  org.slf4j.Logger logger
           
 
Constructor Summary
EhCacheInterceptor()
           
 
Method Summary
protected  void cacheException(CacheableAttribute cacheableAttribute, org.aopalliance.intercept.MethodInvocation methodInvocation, java.io.Serializable key, java.lang.Throwable t)
          Checks CacheableAttribute#getExceptionCache(), if not null the exception will be cached.
protected  void checkForCachedException(CacheableAttribute cacheableAttribute, org.aopalliance.intercept.MethodInvocation methodInvocation, java.io.Serializable key)
          Check if there is a cached exception for the key.
protected  java.io.Serializable generateCacheKey(org.aopalliance.intercept.MethodInvocation methodInvocation, MethodAttribute methodAttribute)
          Creates a Serializable cache key from the MethodInvocation and configuration attributes.
 java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
           
 void setCacheAttributeSource(CacheAttributeSource cacheableAttributeSource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Constructor Detail

EhCacheInterceptor

public EhCacheInterceptor()
Method Detail

setCacheAttributeSource

public void setCacheAttributeSource(CacheAttributeSource cacheableAttributeSource)

invoke

public final java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
                              throws java.lang.Throwable
Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Throws:
java.lang.Throwable

checkForCachedException

protected void checkForCachedException(CacheableAttribute cacheableAttribute,
                                       org.aopalliance.intercept.MethodInvocation methodInvocation,
                                       java.io.Serializable key)
                                throws java.lang.Throwable
Check if there is a cached exception for the key. If there is throw it.

Parameters:
cacheableAttribute - Configuration for the method invocation
key - The cache key for the method invocation
Throws:
java.lang.Throwable - The cached throwable

cacheException

protected void cacheException(CacheableAttribute cacheableAttribute,
                              org.aopalliance.intercept.MethodInvocation methodInvocation,
                              java.io.Serializable key,
                              java.lang.Throwable t)
Checks CacheableAttribute#getExceptionCache(), if not null the exception will be cached.

Parameters:
cacheableAttribute - Configuration for the method invocation
key - Cache key for the invocation
t - The exception to cache

generateCacheKey

protected java.io.Serializable generateCacheKey(org.aopalliance.intercept.MethodInvocation methodInvocation,
                                                MethodAttribute methodAttribute)
Creates a Serializable cache key from the MethodInvocation and configuration attributes.

Parameters:
methodInvocation - Invocation to build the key for
methodAttribute - Configuration for the invoked method
Returns:
Generated cache key, must not return null.


Copyright © 2011. All Rights Reserved.