+ refactor a bit the internals of CacheAspect to allow invocations that do not throw any exceptions (AspectJ)
This commit is contained in:
Costin Leau
2011-09-02 15:37:42 +00:00
parent 91251812b1
commit d9de19d7b3
13 changed files with 180 additions and 58 deletions

View File

@@ -24,6 +24,7 @@ import org.aspectj.lang.annotation.SuppressAjWarnings;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.cache.interceptor.CacheAspectSupport;
import org.springframework.cache.interceptor.CacheOperationSource;
import org.springframework.cache.interceptor.CacheAspectSupport.Invoker;
/**
* Abstract superaspect for AspectJ cache aspects. Concrete
@@ -60,17 +61,13 @@ public abstract aspect AbstractCacheAspect extends CacheAspectSupport {
MethodSignature methodSignature = (MethodSignature) thisJoinPoint.getSignature();
Method method = methodSignature.getMethod();
Callable<Object> ajInvocation = new Callable<Object>() {
public Object call() {
Invoker aspectJInvoker = new Invoker() {
public Object invoke() {
return proceed(cachedObject);
}
};
try{
return execute(ajInvocation, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs());
} catch (Exception ex){
throw new RuntimeException("Cannot cache target ", ex);
}
return execute(aspectJInvoker, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs());
}
/**