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.

AspectOfInterface.java 550B

12345678910111213141516171819202122232425
  1. import org.aspectj.testing.Tester;
  2. public class AspectOfInterface {
  3. public static void main(String[] args) { test(); }
  4. public static boolean ranAdvice = false;
  5. public static void test() {
  6. new C().foo();
  7. Tester.check(ranAdvice, "advice on interface");
  8. }
  9. }
  10. interface I {
  11. public void foo();
  12. }
  13. class C implements I {
  14. public void foo() { } //System.out.println("foo"); }
  15. }
  16. aspect A /*of eachobject(instanceof(I))*/ {
  17. before(): call(* *(..)) {
  18. AspectOfInterface.ranAdvice = true; //System.out.println("before");
  19. }
  20. }