From e9ab1a7abb24f6bfc22df6365c0aa52446808968 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Thu, 22 Dec 2011 13:38:57 +0200 Subject: [PATCH] Update cache ref docs re 'args' vs 'params' naming Prior to this change, the caching reference docs referred to 'root.params', whereas the actual naming should be 'root.args'. This naming was also reflected in the "#p" syntax for specifying method args. This change updates the documentation to refer to 'root.args' properly and also adds "#a" syntax for specifying method arguments more intuitively. Note that "#p" syntax remains in place as an alias for backward compatibility. Issue: SPR-8938 --- .../LazyParamAwareEvaluationContext.java | 1 + .../config/AnnotatedClassCacheableService.java | 4 ++-- spring-framework-reference/src/cache.xml | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/cache/interceptor/LazyParamAwareEvaluationContext.java b/org.springframework.context/src/main/java/org/springframework/cache/interceptor/LazyParamAwareEvaluationContext.java index 5227e43b4c..c8c3e27905 100644 --- a/org.springframework.context/src/main/java/org/springframework/cache/interceptor/LazyParamAwareEvaluationContext.java +++ b/org.springframework.context/src/main/java/org/springframework/cache/interceptor/LazyParamAwareEvaluationContext.java @@ -97,6 +97,7 @@ class LazyParamAwareEvaluationContext extends StandardEvaluationContext { // save arguments as indexed variables for (int i = 0; i < this.args.length; i++) { + setVariable("a" + i, this.args[i]); setVariable("p" + i, this.args[i]); } diff --git a/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java b/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java index 573a5d8ffc..80fa6f50e2 100644 --- a/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java +++ b/org.springframework.context/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java @@ -116,7 +116,7 @@ public class AnnotatedClassCacheableService implements CacheableService return counter.getAndIncrement(); } - @Caching(evict = { @CacheEvict("primary"), @CacheEvict(value = "secondary", key = "#p0"), @CacheEvict(value = "primary", key = "#p0 + 'A'") }) + @Caching(evict = { @CacheEvict("primary"), @CacheEvict(value = "secondary", key = "#a0"), @CacheEvict(value = "primary", key = "#p0 + 'A'") }) public Object multiEvict(Object arg1) { return counter.getAndIncrement(); } @@ -126,7 +126,7 @@ public class AnnotatedClassCacheableService implements CacheableService return counter.getAndIncrement(); } - @Caching(cacheable = { @Cacheable(value = "primary", condition = "#p0 == 3") }, evict = { @CacheEvict("secondary") }) + @Caching(cacheable = { @Cacheable(value = "primary", condition = "#a0 == 3") }, evict = { @CacheEvict("secondary") }) public Object multiConditionalCacheAndEvict(Object arg1) { return counter.getAndIncrement(); } diff --git a/spring-framework-reference/src/cache.xml b/spring-framework-reference/src/cache.xml index 690c96c2f7..e48b750c87 100644 --- a/spring-framework-reference/src/cache.xml +++ b/spring-framework-reference/src/cache.xml @@ -195,10 +195,10 @@ public Book findBook(String name)]]> #root.targetClass - params + args root object The arguments (as array) used for invoking the target - #root.params[0] + #root.args[0] caches @@ -207,12 +207,12 @@ public Book findBook(String name)]]> #root.caches[0].name - parameter name + argument name evaluation context - Name of any of the method parameter. If for some reason the names are not available (ex: no debug information), - the parameter names are also available under the ]]> where - stands for the parameter index (starting from 0). - iban or p0 + Name of any of the method argument. If for some reason the names are not available (ex: no debug information), + the argument names are also available under the ]]> where + stands for the argument index (starting from 0). + iban or a0 (one can also use p0 or ]]> notation as an alias).