blob: db8ba6b24aadc9f7add1a3c144b4561930e6288d (
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
|
import java.util.*;
public aspect JoinPointInAroundAdvice {
static int i = 0;
static int j = 0;
before () : call(* JoinPointInAroundAdvice.privateMethod(..)) { i++; tjps.add(thisJoinPoint.getSourceLocation());}
before () : call(* JoinPointInAroundAdvice.publicMethod(..)) { j++;}
pointcut execTest () : execution(* JoinPointInAroundAdvice.test());
before () : execTest() {
privateMethod("before");
publicMethod("before");
}
void around () : execTest() {
privateMethod("around");
publicMethod("around");
proceed();
}
after () : execTest () {
privateMethod("after");
publicMethod("after");
}
private static List tjps = new ArrayList();
private static void privateMethod(String from) { }//System.out.println("? privateMethod() " + from); }
public static void publicMethod(String from) { }//System.out.println("? publicMethod() " + from); }
public static void test () {
System.out.println("? test()");
}
public static void main (String[] args) {
test();
if (i!=j || i!=3) throw new RuntimeException("Missing join point: private="+i+" public="+j);
//System.err.println(tjps);
}
}
|