blob: e4cc3f1be11318602be4849fcbd6639385e8376d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public class GenericAspectWithAnnotationTypeParameter {
@AnnOne
@AnnTwo
public static void main(String[] args) {
System.out.println("hello");
}
}
@Retention(RetentionPolicy.RUNTIME)
@interface AnnOne {}
@interface AnnTwo {}
abstract aspect AnnotationMatcher<A extends Annotation> {
before() : execution(* *(..)) && @annotation(A) {
System.out.println("annotation match - no binding");
}
before() : execution(@A * *(..)) {
System.out.println("execution with annotation match");
}
before(A anAnnotation) : execution(* *(..)) && @annotation(anAnnotation) {
System.out.println("annotation match - binding");
}
}
aspect AnnOneMatcher extends AnnotationMatcher<AnnOne> {}
|