blob: 2b77e8e4c0616bbc48803a3aeac8495040747f7b (
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
|
import org.aspectj.testing.Tester;
public class AroundAndCalls {
public static void main(String[] args) {
Tester.checkEqual(new CL().go(), "basic-advised");
}
}
aspect MustAspect /*of eachobject(instanceof(CL))*/ {
pointcut parseCalls(CP cp, String cmd):
(args(cmd) && target(cp) && call(String CP.parse(String))) &&
within(CL);
String around(CP cp, String cmd): parseCalls(cp, cmd) {
return proceed(cp, cmd + "-advised");
}
}
class CL {
String go() {
return new CP().parse("basic");
}
}
class CP {
String parse(String cmd) {
return cmd;
}
}
|