blob: 2327881b47fac84b966fed27a0f3a5c5e592267a (
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
|
import org.aspectj.lang.annotation.*;
public class SimpleBefore {
public static void main(String []argv) {
SimpleBefore instance = new SimpleBefore();
X.s.append("1");
instance.m();
if (!X.s.toString().equals("1b2"))
throw new RuntimeException("Either advice not run or ordering wrong, expected 1b2: "+X.s);
}
public void m() {
X.s.append("2");
}
@Aspect("issingleton")
public static class X {
public static StringBuffer s = new StringBuffer("");
@Before("execution(* SimpleBefore.m())")
public void before() {
s.append("b");
}
}
}
|