blob: fe0b1b798b87f0e0efeaf679bb66c305c2b49c68 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
import org.aspectj.testing.Tester;
import org.aspectj.testing.Tester;
public class AspectOf {
public static void main(String[] args) {
Tester.expectEvent("IsSingleton before AspectOf.run()");
Tester.expectEvent("PerCFlow before AspectOf.run()");
Tester.expectEvent("PerTarget before AspectOf.run()");
Tester.expectEvent("PerThis before AspectOf.run()");
Tester.expectEvent("PerCFlowBelow before AspectOf.subrun()");
Tester.expectEvent("run()");
Tester.expectEvent("subrun()");
new AspectOf().run();
Tester.checkAllEvents();
}
public void subrun() {
Object aspect = PerCFlowBelow.aspectOf();
Tester.check(null != aspect, "PerCFlowBelow.aspectOf()");
Tester.event("subrun()");
}
public void run() {
Object aspect = null;
aspect = IsSingleton.aspectOf();
Tester.check(null != aspect, "IsSingleton.aspectOf()");
aspect = PerThis.aspectOf(this);
Tester.check(null != aspect, "PerThis.aspectOf(this)");
aspect = PerTarget.aspectOf(this);
Tester.check(null != aspect, "PerTarget.aspectOf(this)");
aspect = PerCFlow.aspectOf();
Tester.check(null != aspect, "PerCFlow.aspectOf()");
Tester.event("run()");
subrun();
}
public static void log(String s) {
Tester.event(s);
//System.out.println(s);
}
}
aspect IsSingleton {
before() : execution(void AspectOf.run()) {
AspectOf.log("IsSingleton before AspectOf.run()");
}
}
aspect PerThis perthis(pc()) {
pointcut pc() : execution(void AspectOf.run()) ;
before() : pc() {
AspectOf.log("PerThis before AspectOf.run()");
}
}
aspect PerTarget pertarget(pc()) {
pointcut pc() : execution(void AspectOf.run()) ;
before() : pc() {
AspectOf.log("PerTarget before AspectOf.run()");
}
}
aspect PerCFlow percflow(pc()) {
pointcut pc() : execution(void AspectOf.run());
before() : pc() {
AspectOf.log("PerCFlow before AspectOf.run()");
}
}
aspect PerCFlowBelow percflowbelow(pc()) {
pointcut pc() : execution(void AspectOf.run());
before() : execution(void AspectOf.subrun()) {
AspectOf.log("PerCFlowBelow before AspectOf.subrun()");
}
}
|