Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import org.aspectj.testing.Tester;
  2. import org.aspectj.testing.Tester;
  3. public class AspectOf {
  4. public static void main(String[] args) {
  5. Tester.expectEvent("IsSingleton before AspectOf.run()");
  6. Tester.expectEvent("PerCFlow before AspectOf.run()");
  7. Tester.expectEvent("PerTarget before AspectOf.run()");
  8. Tester.expectEvent("PerThis before AspectOf.run()");
  9. Tester.expectEvent("PerCFlowBelow before AspectOf.subrun()");
  10. Tester.expectEvent("run()");
  11. Tester.expectEvent("subrun()");
  12. new AspectOf().run();
  13. Tester.checkAllEvents();
  14. }
  15. public void subrun() {
  16. Object aspect = PerCFlowBelow.aspectOf();
  17. Tester.check(null != aspect, "PerCFlowBelow.aspectOf()");
  18. Tester.event("subrun()");
  19. }
  20. public void run() {
  21. Object aspect = null;
  22. aspect = IsSingleton.aspectOf();
  23. Tester.check(null != aspect, "IsSingleton.aspectOf()");
  24. aspect = PerThis.aspectOf(this);
  25. Tester.check(null != aspect, "PerThis.aspectOf(this)");
  26. aspect = PerTarget.aspectOf(this);
  27. Tester.check(null != aspect, "PerTarget.aspectOf(this)");
  28. aspect = PerCFlow.aspectOf();
  29. Tester.check(null != aspect, "PerCFlow.aspectOf()");
  30. Tester.event("run()");
  31. subrun();
  32. }
  33. public static void log(String s) {
  34. Tester.event(s);
  35. //System.out.println(s);
  36. }
  37. }
  38. aspect IsSingleton {
  39. before() : execution(void AspectOf.run()) {
  40. AspectOf.log("IsSingleton before AspectOf.run()");
  41. }
  42. }
  43. aspect PerThis perthis(pc()) {
  44. pointcut pc() : execution(void AspectOf.run()) ;
  45. before() : pc() {
  46. AspectOf.log("PerThis before AspectOf.run()");
  47. }
  48. }
  49. aspect PerTarget pertarget(pc()) {
  50. pointcut pc() : execution(void AspectOf.run()) ;
  51. before() : pc() {
  52. AspectOf.log("PerTarget before AspectOf.run()");
  53. }
  54. }
  55. aspect PerCFlow percflow(pc()) {
  56. pointcut pc() : execution(void AspectOf.run());
  57. before() : pc() {
  58. AspectOf.log("PerCFlow before AspectOf.run()");
  59. }
  60. }
  61. aspect PerCFlowBelow percflowbelow(pc()) {
  62. pointcut pc() : execution(void AspectOf.run());
  63. before() : execution(void AspectOf.subrun()) {
  64. AspectOf.log("PerCFlowBelow before AspectOf.subrun()");
  65. }
  66. }