blob: 16d3494497f84b450d8a67f4ba50699dbe8e0f0e (
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
43
44
45
|
import org.aspectj.testing.Tester;
public class IntroOrder {
public static void main(String[] args) {
Persist.HasPersistor hp1 = new Class1();
Persist.HasPersistor hp2 = new Class2();
Persistor p = new Persistor();
hp1.setPersistor(p);
Tester.checkEqual(p, hp1.getPersistor(), "basic intro");
}
}
class Class1 {}
class Class2 {}
aspect A1 {
declare parents: Class1 implements Persist.HasPersistor;
}
abstract aspect Persist {
interface HasPersistor {
// introduction below specifies this interface
}
private Persistor HasPersistor.persistor;
public void HasPersistor.setPersistor(Persistor p) { persistor = p; }
public Persistor HasPersistor.getPersistor() { return persistor; }
abstract pointcut readMethods();
abstract pointcut writeMethods();
//advices
}
aspect A2 extends Persist {
declare parents: Class2 implements HasPersistor;
// concretize pointcuts
pointcut readMethods();
pointcut writeMethods();
}
class Persistor {}
|