blob: 176ce20110755c729cdea2d92fa92f464ad0d76a (
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
|
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.*;
public aspect Code4 {
void around(Foo targeto, String s): call(* Foo.run(String)) && args(s) && target(targeto) {
System.out.println("first: binding target, just passing everything through");
proceed(targeto, s);
}
public static void main(String []argv) {
new Foo(0).execute();
}
}
class Foo {
int i;
public Foo(int i) {
this.i = i;
}
public void execute() {
Foo f1 = new Foo(1);
Foo f2 = new Foo(2);
f1.run("abc");
}
public void run(String s) {
System.out.println("Executing run("+s+") on "+this.toString());
}
public String toString() {
return ("Foo(i="+i+")");
}
}
|