How to define an aspectj pointcut that picks out all constructors of a class that has a specific annotation?

Posted by PineForest on Stack Overflow See other posts from Stack Overflow or by PineForest
Published on 2012-08-29T18:36:32Z Indexed on 2012/08/31 3:38 UTC
Read the original article Hit count: 134

Here is the annotation:

@Target(value = ElementType.TYPE)
@Retention(value = RetentionPolicy.RUNTIME)
@Inherited
public @interface MyAnnotation {
    String name();
}

Here is one annotated class:

@MyAnnotation(name="foo")
public class ClassA {
    public ClassA() {
        // Do something
    }
}

Here is a second annotated class:

@MyAnnotation(name="bar")
public class ClassB {
    public ClassB(String aString) {
        // Do something
    }
}

I am looking for an aspectj pointcut that correctly matches the constructors for ClassA and ClassB while not matching any other constructor for any other class NOT annotated by MyAnnotation.

© Stack Overflow or respective owner

Related posts about constructor

Related posts about annotations