blob: ee11f39599d91dcb748d61966f8cfd657fe96192 (
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
|
// TESTING: factory method takes the object for which the delegate exists
import org.aspectj.lang.annotation.*;
public class CaseC {
public static void main(String[]argv) {
CaseC cc = new CaseC();
((I)cc).methodOne(); // will only succeed if mixin applied
}
public String toString() {
return "CaseC instance";
}
}
aspect X {
@DeclareMixin("CaseC")
public static I createImplementation(Object o) {
System.out.println("Delegate factory invoked for "+o.toString());
return new Implementation();
}
}
interface I {
void methodOne();
}
class Implementation implements I {
public void methodOne() {
System.out.println("methodOne running");
}
}
|