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.

PointcutExpression.java 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /* *******************************************************************
  2. * Copyright (c) 2004 IBM Corporation.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * ******************************************************************/
  10. package org.aspectj.weaver.tools;
  11. import java.lang.reflect.Constructor;
  12. import java.lang.reflect.Field;
  13. import java.lang.reflect.Member;
  14. import java.lang.reflect.Method;
  15. /**
  16. * Represents an AspectJ pointcut expression and provides convenience methods to determine
  17. * whether or not the pointcut matches join points specified in terms of the
  18. * java.lang.reflect interfaces.
  19. */
  20. public interface PointcutExpression {
  21. /**
  22. * Set the matching context to be used for
  23. * subsequent calls to match.
  24. * @see MatchingContext
  25. */
  26. void setMatchingContext(MatchingContext aMatchContext);
  27. /**
  28. * Determine whether or not this pointcut could ever match a join point in the given class.
  29. * @param aClass the candidate class
  30. * @return true iff this pointcut <i>may</i> match a join point within(aClass), and false otherwise
  31. */
  32. boolean couldMatchJoinPointsInType(Class aClass);
  33. /**
  34. * Returns true iff this pointcut contains any expression that might necessitate a dynamic test
  35. * at some join point (e.g. args)
  36. */
  37. boolean mayNeedDynamicTest();
  38. /**
  39. * Determine whether or not this pointcut matches the execution of a given method.
  40. * @param aMethod the method being executed
  41. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  42. * matches join points representing the execution of the method.
  43. */
  44. ShadowMatch matchesMethodExecution(Method aMethod );
  45. /**
  46. * Determine whether or not this pointcut matches the execution of a given constructor.
  47. * @param aConstructor the constructor being executed
  48. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  49. * matches join points representing the execution of the constructor.
  50. */
  51. ShadowMatch matchesConstructorExecution(Constructor aConstructor);
  52. /**
  53. * Determine whether or not this pointcut matches the static initialization
  54. * of the given class.
  55. * @param aClass the class being statically initialized
  56. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  57. * matchs join points representing the static initialization of the given type
  58. */
  59. ShadowMatch matchesStaticInitialization(Class aClass);
  60. /**
  61. * Determine whether or not this pointcut matches the execution of a given piece of advice.
  62. * @param anAdviceMethod a method representing the advice being executed
  63. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  64. * matches join points representing the execution of the advice.
  65. */
  66. ShadowMatch matchesAdviceExecution(Method anAdviceMethod);
  67. /**
  68. * Determine whether or not this pointcut matches the initialization of an
  69. * object initiated by a call to the given constructor.
  70. * @param aConstructor the constructor initiating the initialization
  71. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  72. * matches join points representing initialization via the given constructor.
  73. */
  74. ShadowMatch matchesInitialization(Constructor aConstructor);
  75. /**
  76. * Determine whether or not this pointcut matches the pre-initialization of an
  77. * object initiated by a call to the given constructor.
  78. * @param aConstructor the constructor initiating the initialization
  79. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  80. * matches join points representing pre-initialization via the given constructor.
  81. */
  82. ShadowMatch matchesPreInitialization(Constructor aConstructor);
  83. /**
  84. * Determine whether or not this pointcut matches a method call to the given method, made during
  85. * the execution of the given method or constructor.
  86. * @param aMethod the method being called
  87. * @param withinCode the Method or Constructor from within which the call is made
  88. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  89. * matches join points representing a call to this method during the execution of the given member.
  90. */
  91. ShadowMatch matchesMethodCall(Method aMethod, Member withinCode);
  92. /**
  93. * Determine whether or not this pointcut matches a method call to the given method, made outside
  94. * of the scope of any method or constructor, but within the callerType (for example, during
  95. * static initialization of the type).
  96. * @param aMethod the method being called
  97. * @param callerType the declared type of the caller
  98. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  99. * matches join points representing a call to this method during the execution of the given member.
  100. */
  101. ShadowMatch matchesMethodCall(Method aMethod, Class callerType);
  102. /**
  103. * Determine whether or not this pointcut matches a method call to the given constructor, made during
  104. * the execution of the given method or constructor.
  105. * @param aConstructor the constructor being called
  106. * @param withinCode the Method or Constructor from within which the call is made
  107. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  108. * matches join points representing a call to this constructor during the execution of the given member.
  109. */
  110. ShadowMatch matchesConstructorCall(Constructor aConstructor, Member withinCode);
  111. /**
  112. * Determine whether or not this pointcut matches a method call to the given constructor, made outside
  113. * of the scope of any method or constructor, but within the callerType.
  114. * @param aConstructor the cosstructor being called
  115. * @param callerType the declared type of the caller
  116. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never
  117. * matches join points representing a call to this constructor during the execution of the given member.
  118. */
  119. ShadowMatch matchesConstructorCall(Constructor aConstructor, Class callerType);
  120. /**
  121. * Determine whether or not this pointcut matches the execution of a given exception
  122. * handler within the given method or constructor
  123. * @param exceptionType the static type of the exception being handled
  124. * @param withinCode the method or constructor in which the catch block is declared
  125. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or
  126. * never matches join points representing the handling of the given exception
  127. */
  128. ShadowMatch matchesHandler(Class exceptionType, Member withinCode);
  129. /**
  130. * Determine whether or not this pointcut matches the execution of a given exception
  131. * handler outside of the scope of any method or constructor, but within the handling type.
  132. * @param exceptionType the static type of the exception being handled
  133. * @param handlingType the type in which the handler block is executing
  134. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or
  135. * never matches join points representing the handling of the given exception
  136. */
  137. ShadowMatch matchesHandler(Class exceptionType, Class handlingType);
  138. /**
  139. * Determine whether or not this pointcut matches a set of the given field from within the given
  140. * method or constructor.
  141. * @param aField the field being updated
  142. * @param withinCode the Method or Constructor owning the call site
  143. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or
  144. * never matches field set join points for the given field and call site.
  145. */
  146. ShadowMatch matchesFieldSet(Field aField, Member withinCode);
  147. /**
  148. * Determine whether or not this pointcut matches a set of the given field outside of the
  149. * scope of any method or constructor, but within the given type (for example, during
  150. * static initialization).
  151. * @param aField the field being updated
  152. * @param withinType the type owning the call site
  153. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or
  154. * never matches field set join points for the given field and call site.
  155. */
  156. ShadowMatch matchesFieldSet(Field aField, Class withinType);
  157. /**
  158. * Determine whether or not this pointcut matches a get of the given field from within the given
  159. * method or constructor.
  160. * @param aField the field being updated
  161. * @param withinCode the Method or Constructor owning the call site
  162. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or
  163. * never matches field get join points for the given field and call site.
  164. */
  165. ShadowMatch matchesFieldGet(Field aField, Member withinCode);
  166. /**
  167. * Determine whether or not this pointcut matches a get of the given field outside of the
  168. * scope of any method or constructor, but within the given type (for example, during
  169. * static initialization).
  170. * @param aField the field being accessed
  171. * @param withinType the type owning the call site
  172. * @return a ShadowMatch indicating whether the pointcut always, sometimes, or
  173. * never matches field get join points for the given field and call site.
  174. */
  175. ShadowMatch matchesFieldGet(Field aField, Class withinType);
  176. /**
  177. * Return a string representation of this pointcut expression.
  178. */
  179. String getPointcutExpression();
  180. }