Just to complete the last answer:
@Before(value="execution(* *(@CustomAnnotation (*), ..)) && args(input, ..)")
public void inspect(JoinPoint jp, Object input) {
LOGGER.info(">>> inspecting "+input+" on "+jp.getTarget()+", "+jp.getSignature());
}
will match a method where (one of) the argument of the method is annotated with @CustomAnnotation
, for example:
service.doJob(@CustomAnnotation Pojo arg0, String arg1);
In contrast to
@Before(value="execution(* *(@CustomAnnotation *, ..)) && args(input, ..)")
public void inspect(JoinPoint jp, Object input) {
LOGGER.info(">>> inspecting "+input+" on "+jp.getTarget()+", "+jp.getSignature());
}
which will match methods where (one of) the argument's class is annotated with @CustomAnnotation
, for example:
service.doJob(AnnotatedPojo arg0, String arg1);
where the pojo is declared as follows:
@CustomAnnotation
public class AnnotatedPojo {
}
All the difference lies in the @CustomAnnotation (*)
vs. @CustomAnnotation *
in the pointcut declaration.