blob: ad163d007de7abd9b90d18b47c2482ccd1425aa9 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME) @interface Tx {boolean value() default false;}
public aspect DoubleAnnotationMatching {
pointcut methodInTxType(Tx tx) :
execution(* *(..)) && @this(tx) && if(tx.value());
pointcut txMethod(Tx tx) :
execution(* *(..)) && @annotation(tx) && if(tx.value());
pointcut transactionalOperation() :
methodInTxType(Tx) || txMethod(Tx);
before() : transactionalOperation() {
System.err.println("advice running at "+thisJoinPoint);
}
public static void main(String [] argv) {
new Foo().a();
new Foo().b();
new Foo().c();
new TxTrueFoo().a();
new TxTrueFoo().b();
new TxTrueFoo().c();
new TxFalseFoo().a();
new TxFalseFoo().b();
new TxFalseFoo().c();
}
}
@Tx(true) class TxTrueFoo {
@Tx(true) public void a() {}
@Tx(false) public void b() {}
public void c() {}
}
@Tx(false) class TxFalseFoo {
@Tx(true) public void a() {}
@Tx(false) public void b() {}
public void c() {}
}
class Foo {
@Tx(true) public void a() {}
@Tx(false) public void b() {}
public void c() {}
}
|