Skip to content

Commit e9ab1a7

Browse files
Costin Leaucbeams
Costin Leau
authored andcommitted
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
1 parent 02cd868 commit e9ab1a7

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

org.springframework.context/src/main/java/org/springframework/cache/interceptor/LazyParamAwareEvaluationContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private void loadArgsAsVariables() {
9797

9898
// save arguments as indexed variables
9999
for (int i = 0; i < this.args.length; i++) {
100+
setVariable("a" + i, this.args[i]);
100101
setVariable("p" + i, this.args[i]);
101102
}
102103

org.springframework.context/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public Object multiCache(Object arg1) {
116116
return counter.getAndIncrement();
117117
}
118118

119-
@Caching(evict = { @CacheEvict("primary"), @CacheEvict(value = "secondary", key = "#p0"), @CacheEvict(value = "primary", key = "#p0 + 'A'") })
119+
@Caching(evict = { @CacheEvict("primary"), @CacheEvict(value = "secondary", key = "#a0"), @CacheEvict(value = "primary", key = "#p0 + 'A'") })
120120
public Object multiEvict(Object arg1) {
121121
return counter.getAndIncrement();
122122
}
@@ -126,7 +126,7 @@ public Object multiCacheAndEvict(Object arg1) {
126126
return counter.getAndIncrement();
127127
}
128128

129-
@Caching(cacheable = { @Cacheable(value = "primary", condition = "#p0 == 3") }, evict = { @CacheEvict("secondary") })
129+
@Caching(cacheable = { @Cacheable(value = "primary", condition = "#a0 == 3") }, evict = { @CacheEvict("secondary") })
130130
public Object multiConditionalCacheAndEvict(Object arg1) {
131131
return counter.getAndIncrement();
132132
}

spring-framework-reference/src/cache.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ public Book findBook(String name)]]></programlisting>
195195
<entry><screen>#root.targetClass</screen></entry>
196196
</row>
197197
<row>
198-
<entry>params</entry>
198+
<entry>args</entry>
199199
<entry>root object</entry>
200200
<entry>The arguments (as array) used for invoking the target</entry>
201-
<entry><screen>#root.params[0]</screen></entry>
201+
<entry><screen>#root.args[0]</screen></entry>
202202
</row>
203203
<row>
204204
<entry>caches</entry>
@@ -207,12 +207,12 @@ public Book findBook(String name)]]></programlisting>
207207
<entry><screen>#root.caches[0].name</screen></entry>
208208
</row>
209209
<row>
210-
<entry><emphasis>parameter name</emphasis></entry>
210+
<entry><emphasis>argument name</emphasis></entry>
211211
<entry>evaluation context</entry>
212-
<entry>Name of any of the method parameter. If for some reason the names are not available (ex: no debug information),
213-
the parameter names are also available under the <literal><![CDATA[p<#arg>]]></literal> where
214-
<emphasis><![CDATA[#arg]]></emphasis> stands for the parameter index (starting from 0).</entry>
215-
<entry><screen>iban</screen> or <screen>p0</screen></entry>
212+
<entry>Name of any of the method argument. If for some reason the names are not available (ex: no debug information),
213+
the argument names are also available under the <literal><![CDATA[a<#arg>]]></literal> where
214+
<emphasis><![CDATA[#arg]]></emphasis> stands for the argument index (starting from 0).</entry>
215+
<entry><screen>iban</screen> or <screen>a0</screen> (one can also use <screen>p0</screen> or <literal><![CDATA[p<#arg>]]></literal> notation as an alias).</entry>
216216
</row>
217217
</tbody>
218218
</tgroup>

0 commit comments

Comments
 (0)