您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AfterReturningResult.java 742B

1234567891011121314151617181920212223242526272829303132
  1. public class AfterReturningResult {
  2. public static void main (String[] args) {
  3. new CFCommandProcessor().run();
  4. }
  5. }
  6. class CFCommand {
  7. void handleResponse() {}
  8. void updateCache() { System.err.println("updating cache");} }
  9. class CFCommandProcessor {
  10. public void run() {
  11. new CFCommand().handleResponse();
  12. }
  13. }
  14. aspect A {
  15. pointcut response(CFCommand cmd) : within(CFCommandProcessor) &&
  16. target(cmd) &&
  17. call(void CFCommand.handleResponse (..));
  18. after(CFCommand cmd) returning: response(cmd) {
  19. cmd.updateCache();
  20. }
  21. }
  22. aspect B {
  23. Object around(): execution(void run()) {
  24. return proceed();
  25. }
  26. }