@AspectJ advice and pointcut annotations have an optional `argNames` attribute that you
can use to specify the argument names of the annotated method. Note, however, that
explicit `argNames` will only be used by Spring as a fallback if none of the other
`ParameterNameDiscoverer` implementations is able to determine parameter names (see the
previous section for details).
can use to specify the argument names of the annotated method.
[TIP]
====
@ -1579,26 +1579,28 @@ The following example shows how to use the `argNames` attribute:
@@ -1579,26 +1579,28 @@ The following example shows how to use the `argNames` attribute:
----
@Before(
value = "com.xyz.Pointcuts.publicMethod() && target(bean) && @annotation(auditable)", // <1>
argNames = "bean,auditable")
argNames = "bean,auditable") // <2>
public void audit(Object bean, Auditable auditable) {
AuditCode code = auditable.value();
// ... use code and bean
}
----
<1> References the `publicMethod` named pointcut defined in <<aop-pointcuts-combining>>.
<2> Declares `bean` and `auditable` as the argument names.
value = "com.xyz.Pointcuts.publicMethod() && target(bean) && @annotation(auditable)", // <1>
argNames = "bean,auditable")
argNames = "bean,auditable") // <2>
fun audit(bean: Any, auditable: Auditable) {
val code = auditable.value()
// ... use code and bean
}
----
<1> References the `publicMethod` named pointcut defined in <<aop-pointcuts-combining>>.
<2> Declares `bean` and `auditable` as the argument names.
If the first parameter is of type `JoinPoint`, `ProceedingJoinPoint`, or
`JoinPoint.StaticPart`, you can omit the name of the parameter from the value of the
@ -1610,32 +1612,34 @@ point object, the `argNames` attribute does not need to include it:
@@ -1610,32 +1612,34 @@ point object, the `argNames` attribute does not need to include it:
----
@Before(
value = "com.xyz.Pointcuts.publicMethod() && target(bean) && @annotation(auditable)", // <1>
argNames = "bean,auditable")
argNames = "bean,auditable") // <2>
public void audit(JoinPoint jp, Object bean, Auditable auditable) {
AuditCode code = auditable.value();
// ... use code, bean, and jp
}
----
<1> References the `publicMethod` named pointcut defined in <<aop-pointcuts-combining>>.
<2> Declares `bean` and `auditable` as the argument names.