diff --git a/spring-framework-reference/src/aop.xml b/spring-framework-reference/src/aop.xml
index b748bcefe49c3a7117dd545d248a30acd6145df9..76ccf963e616bea876b6a35fb92ad0cd3561e555 100644
--- a/spring-framework-reference/src/aop.xml
+++ b/spring-framework-reference/src/aop.xml
@@ -1275,6 +1275,44 @@ public void audit(Auditable auditable) {
}
+
+ Advice parameters and generics
+
+ Spring AOP can handle generics used in class declarations and
+ method parameters. Suppose you have a generic type like this:
+
+ public interface Sample<T> {
+ void sampleGenericMethod(T param);
+ void sampleGenericCollectionMethod(Collection>T> param);
+}
+
+ You can restrict interception of method types to certain
+ parameter types by simply typing the advice parameter to the
+ parameter type you want to intercept the method for:
+
+ @Before("execution(* ..Sample+.sampleGenericMethod(*)) && args(param)")
+public void beforeSampleMethod(MyType param) {
+ // Advice implementation
+}
+
+ That this works is pretty obvious as we already discussed
+ above. However, it's worth pointing out that this won't work for
+ generic collections. So you cannot define a pointcut like
+ this:
+
+ @Before("execution(* ..Sample+.sampleGenericCollectionMethod(*)) && args(param)")
+public void beforeSampleMethod(Collection<MyType> param) {
+ // Advice implementation
+}
+
+ To make this work we would have to inspect every element of
+ the collection, which is not reasonable as we also cannot decide how
+ to treat null values in general. To achieve
+ something similar to this you have to type the parameter to
+ Collection<?> and manually
+ check the type of the elements.
+
+
Determining argument names