Announcement Announcement Module
No announcement yet.
@args( doesn't work at all Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @args( doesn't work at all

    Hi there,

    i googled much and have searched here either but didn't found a solution yet, maybe some aop expert could help me out.

    I have a joinpoint with @args( for calling an advice for every Method with a parameter, which is annotated by @Annotation. But this doesn't work... I'm also stumbling about the definition with "a single parameter"... I tested it against a method which has really only one parameter (public void xyz(@Annotation String myParam)) with this annotation but the aspect isn't called.

    So how can I do that? I helped myself with a self built AspectJExpressionPointcut and a specialized matcher, looking for the given annotation in the parameterAnnotations array - but @args would be much more readable...


  • #2
    Same problem with @args()

    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:

    public class RestrictionTestImpl implements IRestrictionTest {
    		public void test1(@Restricted("blah") Contact contact){
    			System.out.println("executing test1()");
    ==This works==

    public class RestrictionAdvice {
      @Pointcut("execution(* *(.., (*), ..))")
      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.

    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();