diff --git a/org.springframework.context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java b/org.springframework.context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java index 0dfd4091db3..525b317f3c0 100644 --- a/org.springframework.context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java +++ b/org.springframework.context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java @@ -88,7 +88,6 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser def.setBeanClassName(CACHE_ASPECT_CLASS_NAME); def.setFactoryMethodName("aspectOf"); parseCacheManagerProperty(element, def); - CacheNamespaceHandler.parseKeyGenerator(element, def); parserContext.registerBeanComponent(new BeanComponentDefinition(def, CACHE_ASPECT_BEAN_NAME)); } } @@ -116,6 +115,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser interceptorDef.setSource(eleSource); interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parseCacheManagerProperty(element, interceptorDef); + CacheNamespaceHandler.parseKeyGenerator(element, interceptorDef); interceptorDef.getPropertyValues().add("cacheOperationSources", new RuntimeBeanReference(sourceName)); String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef); diff --git a/org.springframework.context/src/test/java/org/springframework/cache/config/AbstractAnnotationTests.java b/org.springframework.context/src/test/java/org/springframework/cache/config/AbstractAnnotationTests.java index 15eb5e077c1..cad5e470402 100644 --- a/org.springframework.context/src/test/java/org/springframework/cache/config/AbstractAnnotationTests.java +++ b/org.springframework.context/src/test/java/org/springframework/cache/config/AbstractAnnotationTests.java @@ -20,13 +20,11 @@ import static org.junit.Assert.*; import java.util.UUID; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.springframework.aop.framework.AopProxyUtils; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; -import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -286,10 +284,4 @@ public abstract class AbstractAnnotationTests { public void testClassUncheckedException() throws Exception { testUncheckedThrowable(ccs); } - - @Test - public void testKeyStrategy() throws Exception { - CacheInterceptor bean = ctx.getBean("cacheAdviceClass", CacheInterceptor.class); - Assert.assertSame(ctx.getBean("keyGenerator"), bean.getKeyGenerator()); - } } \ No newline at end of file diff --git a/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java b/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java index a30838f743d..92aca03698e 100644 --- a/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java +++ b/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java @@ -16,6 +16,11 @@ package org.springframework.cache.config; +import junit.framework.Assert; + +import org.junit.Test; +import org.springframework.cache.interceptor.CacheInterceptor; + /** * @author Costin Leau @@ -27,4 +32,10 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests { return "/org/springframework/cache/config/annotationDrivenCacheNamespace.xml"; } + @Test + public void testKeyStrategy() throws Exception { + CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0", + CacheInterceptor.class); + Assert.assertSame(ctx.getBean("keyGenerator"), ci.getKeyGenerator()); + } } diff --git a/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotationTests.java b/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotationTests.java index 97c84e894fc..0784bc46b03 100644 --- a/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotationTests.java +++ b/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotationTests.java @@ -17,6 +17,7 @@ package org.springframework.cache.config; + /** * @author Costin Leau */ diff --git a/org.springframework.context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java b/org.springframework.context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java index f45c83ce33c..6fa45351d38 100644 --- a/org.springframework.context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java +++ b/org.springframework.context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java @@ -16,6 +16,10 @@ package org.springframework.cache.config; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.cache.interceptor.CacheInterceptor; + /** * @author Costin Leau @@ -27,4 +31,10 @@ public class CacheAdviceNamespaceTests extends AbstractAnnotationTests { protected String getConfig() { return "/org/springframework/cache/config/cache-advice.xml"; } + + @Test + public void testKeyStrategy() throws Exception { + CacheInterceptor bean = ctx.getBean("cacheAdviceClass", CacheInterceptor.class); + Assert.assertSame(ctx.getBean("keyGenerator"), bean.getKeyGenerator()); + } } diff --git a/org.springframework.context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml b/org.springframework.context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml index db0415562f9..c029a56ce44 100644 --- a/org.springframework.context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml +++ b/org.springframework.context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheConfig.xml @@ -39,5 +39,7 @@ + + diff --git a/org.springframework.context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml b/org.springframework.context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml index b50554e842d..5179346d7f3 100644 --- a/org.springframework.context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml +++ b/org.springframework.context/src/test/resources/org/springframework/cache/config/annotationDrivenCacheNamespace.xml @@ -7,7 +7,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> - + @@ -27,4 +27,6 @@ + +