blob: 7f70c7a6d28ec6afe618f3ab559275ea1f38a0fa (
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
46
47
48
49
50
51
52
|
public aspect Pr113368 {
public static void main(String[] args) {
try {
aspectOf().hook();
} catch (ExceptionInInitializerError ex) {
Throwable cause = ex.getCause();
if (! (cause instanceof org.aspectj.lang.NoAspectBoundException)) {
throw new RuntimeException("Unexpected exception: " + cause);
}
}
}
void hook() {}
private pointcut managedBeanConstruction(ManagedBean bean) :
execution(ManagedBean+.new(..)) && this(bean);
//NPE's on the if pointcut below
private pointcut topLevelManagedBeanConstruction(ManagedBean bean) :
managedBeanConstruction(bean) &&
if(thisJoinPointStaticPart.getSignature().getDeclaringType() == bean.getClass());
after(ManagedBean bean) returning: topLevelManagedBeanConstruction(bean) {
System.out.println("I just constructed " + bean);
}
}
abstract aspect ManagedBean {
}
aspect ManagedSubBean extends ManagedBean {
before() : execution(* hook()) {
}
}
aspect AutoStart {
before() : staticinitialization(ManagedBean) {
ManagedSubBean.aspectOf();
}
}
aspect Tracer {
before() : !within(Tracer) {
System.out.println(thisJoinPoint);
}
}
|