aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/AdviceOnAdvice.java
blob: 174e489e380771a4585af024825c1cb0ba755632 (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
/*
 * To test some stuff
 */

import org.aspectj.testing.*;

public class AdviceOnAdvice {
  public static void main(String[] args) {
    new Class1().a();
    Tester.check(Class1.calledB, "Aspect2 did not get advice");
  }
}

class Class1 {
    public void a() { }
    public void b() { }
    public static boolean calledA = false;
    public static boolean calledB = false;
}


aspect Aspect1 {
    pointcut a(Class1 c1) :
        target(c1) && call(public void a());
    
    void around(Class1 c1) : a(c1) {
        proceed(c1);
        c1.b();
    }
}


aspect Aspect2b {
    
    pointcut b() :
        call(public void Class1.b()) && within(Aspect1);
    
    after () : b() {
        Class1.calledB = true;
    }
}