updated cache aspect after CacheAspectSupport base class changes

This commit is contained in:
Juergen Hoeller 2011-07-22 10:12:07 +00:00
parent df3761e3f6
commit 79ed87e3d5
3 changed files with 16 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2010 the original author or authors. * Copyright 2002-2011 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,8 +36,9 @@ import org.springframework.cache.interceptor.CacheOperationSource;
* <p><b>NB:</b> If a method implements an interface that is itself * <p><b>NB:</b> If a method implements an interface that is itself
* cache annotated, the relevant Spring cache definition * cache annotated, the relevant Spring cache definition
* will <i>not</i> be resolved. * will <i>not</i> be resolved.
*
* @author Costin Leau * @author Costin Leau
* @since 3.1
*/ */
public abstract aspect AbstractCacheAspect extends CacheAspectSupport { public abstract aspect AbstractCacheAspect extends CacheAspectSupport {
@ -50,7 +51,7 @@ public abstract aspect AbstractCacheAspect extends CacheAspectSupport {
* cache metadata for each joinpoint. * cache metadata for each joinpoint.
*/ */
protected AbstractCacheAspect(CacheOperationSource... cos) { protected AbstractCacheAspect(CacheOperationSource... cos) {
setCacheDefinitionSources(cos); setCacheOperationSources(cos);
} }
@SuppressAjWarnings("adviceDidNotMatch") @SuppressAjWarnings("adviceDidNotMatch")
@ -59,7 +60,6 @@ public abstract aspect AbstractCacheAspect extends CacheAspectSupport {
Method method = methodSignature.getMethod(); Method method = methodSignature.getMethod();
Callable<Object> ajInvocation = new Callable<Object>() { Callable<Object> ajInvocation = new Callable<Object>() {
public Object call() { public Object call() {
return proceed(cachedObject); return proceed(cachedObject);
} }
@ -67,7 +67,8 @@ public abstract aspect AbstractCacheAspect extends CacheAspectSupport {
try { try {
return execute(ajInvocation, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs()); return execute(ajInvocation, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs());
} catch (Exception ex) { }
catch (Exception ex) {
throw new UnsupportedOperationException("Should not throw exception", ex); throw new UnsupportedOperationException("Should not throw exception", ex);
} }
} }
@ -78,4 +79,5 @@ public abstract aspect AbstractCacheAspect extends CacheAspectSupport {
* will be retrieved using Spring's {@link CacheOperationSource} interface. * will be retrieved using Spring's {@link CacheOperationSource} interface.
*/ */
protected abstract pointcut cacheMethodExecution(Object cachedObject); protected abstract pointcut cacheMethodExecution(Object cachedObject);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2010 the original author or authors. * Copyright 2002-2011 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,8 +21,7 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
/** /**
* Concrete AspectJ cache aspect using Spring {@link Cacheable} annotation * Concrete AspectJ cache aspect using Spring's {@link Cacheable} annotation.
* for JDK 1.5+.
* *
* <p>When using this aspect, you <i>must</i> annotate the implementation class * <p>When using this aspect, you <i>must</i> annotate the implementation class
* (and/or methods within that class), <i>not</i> the interface (if any) that * (and/or methods within that class), <i>not</i> the interface (if any) that
@ -39,6 +38,7 @@ import org.springframework.cache.annotation.Cacheable;
* to get caching demarcation for the execution of such operations. * to get caching demarcation for the execution of such operations.
* *
* @author Costin Leau * @author Costin Leau
* @since 3.1
*/ */
public aspect AnnotationCacheAspect extends AbstractCacheAspect { public aspect AnnotationCacheAspect extends AbstractCacheAspect {
@ -83,4 +83,5 @@ public aspect AnnotationCacheAspect extends AbstractCacheAspect {
(executionOfAnyPublicMethodInAtCacheableType() || executionOfAnyPublicMethodInAtCacheEvictType() (executionOfAnyPublicMethodInAtCacheableType() || executionOfAnyPublicMethodInAtCacheEvictType()
|| executionOfCacheableMethod() || executionOfCacheEvictMethod()) || executionOfCacheableMethod() || executionOfCacheEvictMethod())
&& this(cachedObject); && this(cachedObject);
} }

View File

@ -13,7 +13,7 @@
<bean id="cacheAspect" class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf"> <bean id="cacheAspect" class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf">
<property name="cacheManager" ref="cacheManager"/> <property name="cacheManager" ref="cacheManager"/>
<property name="cacheDefinitionSources" ref="annotationSource"/> <property name="cacheOperationSource" ref="annotationSource"/>
</bean> </bean>
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager"> <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">