Hi there I have the following code sample 

@Aspect
public class MyAspect {

    @Pointcut("cflowbelow(execution(@CallerAnnotation * *(..)) && 
@annotation(callerAnnotation))")
    protected void executeBelowAnnotation(final CallerAnnotation 
callerAnnotation) {
    }

    @Pointcut(value = "execution(public void callee(String, Integer))")
    protected void executeCallee() {
    }

    @Around("executeCallee() && executeBelowAnnotation(callerAnnotation)")
    public Object finalAdvice(final ProceedingJoinPoint joinPoint, final 
CallerAnnotation callerAnnotation)
            throws Throwable {
        return joinPoint.proceed();
    }
}


public class SampleClazz() {

    @CallerAnnotation("xyz")
    public void caller(Foo foo, Bar bar){
        this.callee();
    }

    private void callee(String s, Integer i){
      // Do Something
    }
}

and I would like to know is there any possibility to use the args such as 
args(..) in order to get the method arguments of the caller method in the 
following example?

I know that I can in my first pointcut define 
 
@Pointcut("cflowbelow(call(@CallerAnnotation * *(..)) && 
@annotation(callerAnnotation) && args(foo, bar))")
    protected void executeBelowAnnotation(final CallerAnnotation 
callerAnnotation, Foo foo, Bar bar) {
    }

So that I also pass on those method params to the finalAdvice method, however I 
would like to do this without explicitly defining the arguments in my pointcut 
so that it doesn’t depend on the signature of the annotated method. 

One way that I have done before has been using another annotation to annotate 
the params and then having @annotation in my pointcut but I would like to see 
whether I can skip having yet another annotation for this. 

Also another way might be the use of executionAdvice and then defining two 
advices and combining them together for the two pointcuts. That way I guess I 
can use the getMethodArgs() from ProceedingJoinPoint.

So is there any way to use the args() to achieve this? 

Regards
Sina



_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://www.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to