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.

AdviceOnAdvice.java 724B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * To test some stuff
  3. */
  4. import org.aspectj.testing.*;
  5. public class AdviceOnAdvice {
  6. public static void main(String[] args) {
  7. new Class1().a();
  8. Tester.check(Class1.calledB, "Aspect2 did not get advice");
  9. }
  10. }
  11. class Class1 {
  12. public void a() { }
  13. public void b() { }
  14. public static boolean calledA = false;
  15. public static boolean calledB = false;
  16. }
  17. aspect Aspect1 {
  18. pointcut a(Class1 c1) :
  19. target(c1) && call(public void a());
  20. void around(Class1 c1) : a(c1) {
  21. proceed(c1);
  22. c1.b();
  23. }
  24. }
  25. aspect Aspect2b {
  26. pointcut b() :
  27. call(public void Class1.b()) && within(Aspect1);
  28. after () : b() {
  29. Class1.calledB = true;
  30. }
  31. }