Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Package Annotations

The  AspectJ 5 Developer's Notebook says:

 

>          For any kind of annotated element (type,
method, constructor, package, etc.), an annotation
pattern can be used to match against the set of
annotations on the annotated element.

 

But I cannot find any way to use package annotations
in aspects.

What I would like to do is add an annotation to some
packages and then write a pointcut that matches all
methods in classes in packages that declare the
annotations.

It would probably look something like:

 

public aspect MyAspect {

    pointcut pc(): execution(* (@MyAnnotation
*).*.*());

 

    before(): pc() {

        System.out.println(“here”);

    }

}

 

But the above is not allowed by the syntax for
TypePattern.

The TypePattern syntax only allows annotations at the
outermost level as far as I can tell.



Back to the top