aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs/IfPerThis/Testcase3.java
blob: c29834338399a94cec7578a0cfdd953f882acf79 (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
// Compiler limitation, can't put if() directly in per clause 
aspect Testcase3 perthis(execution(* doCommand(..)) && if(commandInterceptionEnabled)) {

  private static boolean commandInterceptionEnabled = true;

  public Testcase3() {
	System.out.println("Created a PerThis aspect : " + this.toString());
  }

  before(ICommand command) : execution(* doCommand(..)) && this(command) {
	System.out.println("Invoking command bean:  "+ command);
  }

  public static void main(String[] args) {
	ICommand c1 = new Command("hello");
	ICommand c2 = new Command("hello again");
	c1.doCommand();
	c2.doCommand();
  }

}

interface ICommand {
   void doCommand();
}

class Command implements ICommand {
 
  private String output = "";

  public Command(String s) { this.output = s; }

  public void doCommand() {
	System.out.println(output + "(" + this + ")");
  }
   
}