Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Accessing value of annotation on method parameter

Hi!

I have the following problem:
I want to access the value of an annotation that is annotating a parameter
of a method in my advice function. Is it possible to somehow make the
annotation available to the advice in my pointcut?

For example:

public class A {
    public String annotatedValue;
}

@Target({PARAMETER, FIELD})
@Retention(RUNTIME)
@Documented
public @interface QSChild {
    String value() default "";
}

public class BeanFactoryA {
   public BeanObject generateBeanObject(@QSChild("testvalue") A objectA) {
... }
   ...
}

In my aspect, i want to intercept the call to any generateBeanObject method
and somehow get the value of the @QSChild annotation.

public aspect BeanFactoryAspect {
    pointcut beanFactoryMethod(@QSChild param) : call(* *(@QSChild (*))) &&
//now make the annotation available

    before(@QSChild param) : beanFactoryMethod(param) {
        // do something with the value of the annotation
    }
}


Any help is appreciated,
Luke

--
View this message in context: http://aspectj.2085585.n4.nabble.com/Accessing-value-of-annotation-on-method-parameter-tp4042771p4042771.html
Sent from the AspectJ - users mailing list archive at Nabble.com.


Back to the top