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.

PointcutFormals.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import org.aspectj.testing.*;
  2. public class PointcutFormals {
  3. public static void main(String[] args) {
  4. new PointcutFormals().call(0);
  5. Tester.checkAllEvents();
  6. }
  7. void call(int i) {}
  8. static {
  9. String[] cuts = { "calls_pc", "receptions_pc", "executions_pc" };
  10. String[] kinds = { "before", "after", "around" };
  11. for (int i = 0; i < cuts.length; i++) {
  12. for (int j = 0; j < kinds.length; j++) {
  13. Tester.expectEvent(kinds[j] + "." + cuts[i]);
  14. }
  15. }
  16. }
  17. }
  18. aspect Aspect {
  19. pointcut calls_pc (): call(void *.call(int)) && within(PointcutFormals);
  20. pointcut receptions_pc(): call(void PointcutFormals.call(int));
  21. pointcut executions_pc(): execution(void *(int));
  22. before(): calls_pc () { a("before.calls_pc"); }
  23. before(): receptions_pc() { a("before.receptions_pc"); }
  24. before(): executions_pc() { a("before.executions_pc"); }
  25. after(): calls_pc () { a("after.calls_pc"); }
  26. after(): receptions_pc() { a("after.receptions_pc"); }
  27. after(): executions_pc() { a("after.executions_pc"); }
  28. around() returns void: calls_pc () { a("around.calls_pc"); proceed(); }
  29. around() returns void: receptions_pc() { a("around.receptions_pc"); proceed(); }
  30. around() returns void: executions_pc() { a("around.executions_pc"); proceed(); }
  31. void a(Object msg) {
  32. Tester.event(msg);
  33. }
  34. }