Prior to this commit, common cache operation settings had to be
repeated for every operation: cache name(s), custom cache manager
and custom key manager.
This commit introduces the @CacheConfig annotation to bet set at
class-level (either directly or as a meta-annotation). As the cache
name(s) can be rationalized there, the "value" of the various
annotations are no longer mandatory.
CacheAnnotationParser has an API breakage to be able to retrieve
information at class-level.
Issue: SPR-11316
@ -106,29 +106,40 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
@@ -106,29 +106,40 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
@ -166,4 +177,19 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
@@ -166,4 +177,19 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
@ -82,7 +96,8 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@@ -82,7 +96,8 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@ -92,11 +107,14 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@@ -92,11 +107,14 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@ -107,11 +125,14 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@@ -107,11 +125,14 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@ -121,38 +142,56 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@@ -121,38 +142,56 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@ -173,13 +212,27 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@@ -173,13 +212,27 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
thrownewIllegalStateException("Invalid cache annotation configuration on '"
+ae.toString()+"'. Both 'key' and 'keyGenerator' attributes have been set. "+
"These attributes are mutually exclusive: either set the SpEL expression used to"+
"compute the key at runtime or set the name of the KeyGenerator bean to use.");
}
if(operation.getCacheNames().isEmpty()){
thrownewIllegalStateException("No cache names could be detected on '"
+ae.toString()+"'. Make sure to set the value parameter on the annotation or"+
"declare a @CacheConfig at the class-level with the default cache name(s) to use.");
}
}
@Override
@ -192,4 +245,41 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
@@ -192,4 +245,41 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria