You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AroundAndCalls.java 619B

123456789101112131415161718192021222324252627282930
  1. import org.aspectj.testing.Tester;
  2. public class AroundAndCalls {
  3. public static void main(String[] args) {
  4. Tester.checkEqual(new CL().go(), "basic-advised");
  5. }
  6. }
  7. aspect MustAspect /*of eachobject(instanceof(CL))*/ {
  8. pointcut parseCalls(CP cp, String cmd):
  9. (args(cmd) && target(cp) && call(String CP.parse(String))) &&
  10. within(CL);
  11. String around(CP cp, String cmd): parseCalls(cp, cmd) {
  12. return proceed(cp, cmd + "-advised");
  13. }
  14. }
  15. class CL {
  16. String go() {
  17. return new CP().parse("basic");
  18. }
  19. }
  20. class CP {
  21. String parse(String cmd) {
  22. return cmd;
  23. }
  24. }