0

Spring 3 @AspectJ in use.

One target method below,

public void testParam(@Deprecated String param) {
}

Two advices below,

@Before("args(java.lang.String)")
public void checkStrParam() {
 System.out.println("str param found");
}

@Before("@args(java.lang.Deprecated)")
public void checkDepParam() {
 System.out.println("dep param found");
}

Invocation on the target method only executes the args advice. What does the @args advice lack of?

sof
  • 9,113
  • 16
  • 57
  • 83
  • 1
    If I recall correctly AspectJ can only be triggered on annotations on types. So the second one doesn't trigger unless your parameter type (in this case java.lang.String) would be annotated with `@Deprecated'. See also http://stackoverflow.com/questions/16810617/aspectj-java-instrumentation-to-intercept-an-annoted-parameter-call-usage. – M. Deinum Nov 21 '13 at 13:03
  • Not sure if @args already supported. This paragraph "@args - limits matching to join points (the execution of methods when using Spring AOP) where the runtime type of the actual arguments passed have annotations of the given type(s)" is described from the section "Supported Pointcut Designators" on lastest Spring reference http://docs.spring.io/spring/docs/3.2.5.RELEASE/spring-framework-reference/htmlsingle/#aop-ataspectj – sof Nov 21 '13 at 13:24
  • 1
    Well @args is supported but is only supported when the type has that annotation (as explained in my earlier comment). – M. Deinum Nov 21 '13 at 13:26

0 Answers0