blob: 5aa1afae2b02879911cac07ca9df0c9b7c0d98f9 (
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
|
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.*;
enum Mood {HAPPY,SAD}
@Aspect
public class MoodIndicator4 {
public interface Moody { Mood getMood(); };
public static class MoodyImpl implements Moody {
private Mood mood = Mood.HAPPY;
public Mood getMood() { return mood; }
}
@DeclareMixin("MoodIndicator4")
public static Moody createMoodyImplementation() {
return new MoodyImpl();
}
@Before("execution(* *.run(..)) && this(m)")
public void feelingMoody(Moody m) {
System.out.println("I'm feeling " + m.getMood());
}
public static void main(String[]argv) {
Aspects.aspectOf(MoodIndicator4.class).run();
}
public void run() {
}
}
|