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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. public class AJDBClass {
  2. public int publicInt = 0;
  3. protected int protectedInt = 1;
  4. private int privateInt = 2;
  5. /*package*/ int packageInt = 3;
  6. public AJDBClass() {}
  7. /*package*/ AJDBClass(int i) {}
  8. protected AJDBClass(byte b) {}
  9. private AJDBClass(String s) {}
  10. {
  11. publicInt = 13;
  12. }
  13. public static void main(String[] args) {
  14. System.out.println("Starting...");
  15. new AJDBClass().go();
  16. System.out.println("Done.");
  17. }
  18. void go() {
  19. int j = 1;
  20. String string = "string";
  21. byte b = (byte)9;
  22. long l = 123123123;
  23. double d = 123.123;
  24. short s = (short)4;
  25. char c = 'c';
  26. Object o = null;
  27. Integer integer = new Integer(13);
  28. a();
  29. b();
  30. c();
  31. d();
  32. }
  33. public void a() {
  34. System.out.println("a");
  35. }
  36. protected void b() {
  37. System.out.println("b");
  38. }
  39. private void c() {
  40. System.out.println("c");
  41. }
  42. void d() {
  43. System.out.println("d");
  44. }
  45. }
  46. aspect Aspect {
  47. pointcut ours(): instanceof(AJDBClass);
  48. pointcut allReceptions(): receptions(void *(..)) && ours();
  49. pointcut allExecutions(): executions(void *(..)) && within(AJDBClass);
  50. pointcut allCalls(): calls(void AJDBClass.*(..));
  51. pointcut allCallsTo(): callsto(receptions(void *(..)) && instanceof(AJDBClass));
  52. static before(): allReceptions() {
  53. System.out.println("before receptions: " + thisJoinPoint);
  54. }
  55. static after(): allReceptions() {
  56. System.out.println("after receptions: " + thisJoinPoint);
  57. }
  58. static around() returns void: allReceptions() {
  59. System.out.println("around before receptions: " + thisJoinPoint);
  60. proceed();
  61. System.out.println("around after receptions: " + thisJoinPoint);
  62. }
  63. static before(): allExecutions() {
  64. System.out.println("before executions: " + thisJoinPoint);
  65. }
  66. static after(): allExecutions() {
  67. System.out.println("after executions: " + thisJoinPoint);
  68. }
  69. static around() returns void: allExecutions() {
  70. System.out.println("around before executions: " + thisJoinPoint);
  71. proceed();
  72. System.out.println("around after executions: " + thisJoinPoint);
  73. }
  74. static before(): allCalls() {
  75. System.out.println("before calls: " + thisJoinPoint);
  76. }
  77. static after(): allCalls() {
  78. System.out.println("after calls: " + thisJoinPoint);
  79. }
  80. static around() returns void: allCalls() {
  81. System.out.println("around before calls: " + thisJoinPoint);
  82. proceed();
  83. System.out.println("around after calls: " + thisJoinPoint);
  84. }
  85. static before(): allCallsTo() {
  86. System.out.println("before callsTo: " + thisJoinPoint);
  87. }
  88. static after(): allCallsTo() {
  89. System.out.println("after callsTo: " + thisJoinPoint);
  90. }
  91. static around() returns void: allCallsTo() {
  92. System.out.println("around before callsTo: " + thisJoinPoint);
  93. proceed();
  94. System.out.println("around after callsTo: " + thisJoinPoint);
  95. }
  96. }