summaryrefslogtreecommitdiffstats
path: root/tests/bugs152/pr138223/DoubleAnnotationMatching.aj
blob: 41530942158ef12815df227db2d44e086fb48641 (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
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@interface Tx {
  boolean readOnly() default false;
}

public aspect DoubleAnnotationMatching {


 pointcut methodInTxType(Tx tx) : 
   execution(* *(..)) && @this(tx) && if(tx.readOnly());
   
 pointcut txMethod(Tx tx) :
   execution(* *(..)) && @annotation(tx) && if(tx.readOnly());
   
 pointcut transactionalOperation() :
   methodInTxType(Tx) || txMethod(Tx);
   
 before() : transactionalOperation() {
   // do something
 }

}

@Tx class Foo {

  public void foo() {}
  
  @Tx public void bar() {}


}