I have the same problem. I was able to create a poincut that matches any annotated arguments, but I cannot access the annotation value inside my Advice or get the @args() expression to work. I've tried many diffrent permutations of this, but nothing seems to work. Did you make any progress?
My test class is as follows:
Code:
public class RestrictionTestImpl implements IRestrictionTest {
public void test1(@Restricted("blah") Contact contact){
System.out.println("executing test1()");
}
}
==This works==
Code:
@Aspect
public class RestrictionAdvice {
@Pointcut("execution(* *(.., @my.package.security.Restricted (*), ..))")
private void pc1(){}
@Around("pc1() && args(contact)")
public Object testAdvice1(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("applied testAdvice1");
return pjp.proceed();
}
}
==This doesn't work==
The advice is not called when including @args(anno), but works fine if I remove that and the Restricted param.
Code:
@Aspect
public class RestrictionAdvice2 {
@Pointcut("execution(* my.test.test1(..))")
private void pc2(){}
@Around("pc2() && @args(anno)")
public Object testAdvice2(ProceedingJoinPoint pjp, Restricted anno) throws Throwable {
System.out.println("applied testAdvice2");
System.out.println("annotation value: " + anno.value());
return pjp.proceed();
}
}