blob: 4bd76aeca0c518386f2205db1d48127acac1a908 (
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
|
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.DeclareParents;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class Persistability {
static class Persistable implements IPersistable {
private static final long serialVersionUID = 7120491865883787353L;
private int id;
public Persistable() {
super();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
@DeclareParents(value = "PersistabilityTest", defaultImpl = Persistable.class)
private IPersistable observable;
@Pointcut("initialization(IPersistable.new(..)) && this(bean) && !this(Persistable)")
void init(IPersistable bean) {
}
@Before("init(bean)")
public void beforeInit(IPersistable bean) {
bean.setId(System.identityHashCode(bean));
}
}
|