blob: d50de023cbd2025ae4a39c699d53bf423ba32184 (
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
|
import org.aspectj.testing.*;
public class PointcutFormals {
public static void main(String[] args) {
new PointcutFormals().call(0);
Tester.checkAllEvents();
}
void call(int i) {}
static {
String[] cuts = { "calls_pc", "receptions_pc", "executions_pc" };
String[] kinds = { "before", "after", "around" };
for (int i = 0; i < cuts.length; i++) {
for (int j = 0; j < kinds.length; j++) {
Tester.expectEvent(kinds[j] + "." + cuts[i]);
}
}
}
}
aspect Aspect {
pointcut calls_pc (): call(void *.call(int)) && within(PointcutFormals);
pointcut receptions_pc(): call(void PointcutFormals.call(int));
pointcut executions_pc(): execution(void *(int));
before(): calls_pc () { a("before.calls_pc"); }
before(): receptions_pc() { a("before.receptions_pc"); }
before(): executions_pc() { a("before.executions_pc"); }
after(): calls_pc () { a("after.calls_pc"); }
after(): receptions_pc() { a("after.receptions_pc"); }
after(): executions_pc() { a("after.executions_pc"); }
around() returns void: calls_pc () { a("around.calls_pc"); proceed(); }
around() returns void: receptions_pc() { a("around.receptions_pc"); proceed(); }
around() returns void: executions_pc() { a("around.executions_pc"); proceed(); }
void a(Object msg) {
Tester.event(msg);
}
}
|