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.

SimpleAround1.java 945B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import org.aspectj.testing.*;
  2. import org.aspectj.lang.*;
  3. import org.aspectj.lang.reflect.*;
  4. import java.util.*;
  5. public class SimpleAround1 {
  6. public static void main(String[] args) {
  7. new SimpleAround1().go();
  8. Tester.checkEqual(A.ran, "foo:goo:boo:", "advice didn't run");
  9. }
  10. void go() {
  11. foo("1");
  12. goo("2");
  13. boo("3");
  14. }
  15. void foo(String s) { new Integer(2).toString(); }
  16. void goo(String s) { }
  17. void boo(String s) { }
  18. }
  19. aspect A {
  20. void around(String s): execution(void *.*oo(String)) && args(s){
  21. proceed(s);
  22. JoinPoint jp = thisJoinPoint;
  23. ran += jp.getSignature().getName()+":";
  24. }
  25. static String ran = "";
  26. // When this advice is here no joinpoint is constructed in foo(String)
  27. before(): execution(void *.foo(String)) { }
  28. before(): execution(void *.goo(String)) {thisJoinPoint.getThis(); }
  29. before(): call(* Integer.*(..)) {thisJoinPoint.getThis(); }
  30. }