kopie van
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-09-03 17:56:34 +02:00
33 regels
742 B
Java
33 regels
742 B
Java
public class AfterReturningResult {
|
|
public static void main (String[] args) {
|
|
new CFCommandProcessor().run();
|
|
}
|
|
}
|
|
|
|
class CFCommand {
|
|
void handleResponse() {}
|
|
void updateCache() { System.err.println("updating cache");} }
|
|
|
|
class CFCommandProcessor {
|
|
public void run() {
|
|
new CFCommand().handleResponse();
|
|
}
|
|
}
|
|
|
|
aspect A {
|
|
pointcut response(CFCommand cmd) : within(CFCommandProcessor) &&
|
|
target(cmd) &&
|
|
call(void CFCommand.handleResponse (..));
|
|
|
|
after(CFCommand cmd) returning: response(cmd) {
|
|
cmd.updateCache();
|
|
}
|
|
}
|
|
|
|
|
|
aspect B {
|
|
Object around(): execution(void run()) {
|
|
return proceed();
|
|
}
|
|
}
|