blob: 8b72a27990c0a017744de1e5eb1c39756af7c39f (
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
|
abstract aspect WorkerExample {
after() returning (RequestContext newContext) : call(RequestContext+.new(..)) {
System.out.println("constructing "+newContext+" at "+thisJoinPoint.toLongString()+" from "+thisEnclosingJoinPointStaticPart+":");
}
abstract class RequestContext {
public final Object execute() {
return doExecute();
}
/** template method */
public abstract Object doExecute();
}
public static void main(String args[]) {
new Runnable() {
public void run() {}
}.run();
};
}
aspect ConcreteAlpha extends WorkerExample {
Object around(final Object runnable) : execution(void Runnable.run()) && this(runnable) {
System.out.println("monitoring operation: "+runnable+" at "+thisJoinPoint+", for "+thisJoinPoint.getThis());
RequestContext requestContext = new RequestContext() {
public Object doExecute() {
return proceed(runnable);
}
};
return requestContext.execute();
}
}
aspect ConcreteBeta extends WorkerExample {
Object around() : call(void awqeyuwqer()) {
RequestContext requestContext = new ConnectionRequestContext() {
public Object doExecute() {
return proceed();
}
};
return requestContext.execute();
}
}
|