接口 MethodMatcher
- 所有已知子接口:
IntroductionAwareMethodMatcher
- 所有已知实现类:
AbstractAspectJAdvice.AdviceExcludingMethodMatcher,AbstractRegexpMethodPointcut,AnnotationMethodMatcher,AspectJExpressionPointcut,ControlFlowPointcut,DynamicMethodMatcher,DynamicMethodMatcherPointcut,InstantiationModelAwarePointcutAdvisorImpl.PerTargetInstantiationModelPointcut,JdkRegexpMethodPointcut,MethodMatcher.ClassFilterAwareUnionIntroductionAwareMethodMatcher,MethodMatcher.ClassFilterAwareUnionMethodMatcher,MethodMatcher.IntersectionIntroductionAwareMethodMatcher,MethodMatcher.IntersectionMethodMatcher,MethodMatcher.NegateMethodMatcher,MethodMatcher.UnionIntroductionAwareMethodMatcher,MethodMatcher.UnionMethodMatcher,NameMatchMethodPointcut,Pointcut.GetterPointcut,Pointcut.SetterPointcut,StaticMethodMatcher,StaticMethodMatcherPointcut,StaticMethodMatcherPointcutAdvisor,TrueMethodMatcher
Pointcut: Checks whether the target method is eligible for advice.
A MethodMatcher may be evaluated statically or at runtime (dynamically). Static matching involves method and (possibly) method attributes. Dynamic matching also makes arguments for a particular call available, and any effects of running previous advice applying to the join-point.
If an implementation returns false from its isRuntime()
method, evaluation can be performed statically, and the result will be the same
for all invocations of this method, whatever their arguments. This means that
if the isRuntime() method returns false, the 1-arg
matches(MethodInvocation) method will never be invoked.
If an implementation returns true from its 2-arg
matches(java.lang.reflect.Method, Class) method and its isRuntime() method
returns true, the 1-arg matches(MethodInvocation)
method will be invoked immediately before each potential execution of the related advice,
to decide whether the advice should run. All previous advice, such as earlier interceptors
in an interceptor chain, will have run, so any state changes they have produced in
parameters or ThreadLocal state will be available at the time of evaluation.
WARNING: Concrete implementations of this interface must
provide proper implementations of Object.equals(Object),
Object.hashCode(), and Object.toString() in order to allow the
matcher to be used in caching scenarios — for example, in proxies generated
by CGLIB. As of 4.0, the toString() implementation
must generate a unique string representation that aligns with the logic used
to implement equals(). See concrete implementations of this interface
within the framework for examples.
- 从以下版本开始:
- 3.0
- 作者:
- Rod Johnson, TODAY 2019-10-20 22:43
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型接口说明static classMethodMatcher implementation for a union of two given MethodMatchers of which at least one is an IntroductionAwareMethodMatcher, supporting an associated ClassFilter per MethodMatcher.static classMethodMatcher implementation for a union of two given MethodMatchers, supporting an associated ClassFilter per MethodMatcher.static classMethodMatcher implementation for an intersection of two given MethodMatchers of which at least one is an IntroductionAwareMethodMatcher.static classMethodMatcher implementation for an intersection of two given MethodMatcher.static classstatic classMethodMatcher implementation for a union of two given MethodMatchers of which at least one is an IntroductionAwareMethodMatcher.static classMethodMatcher implementation for a union of two given MethodMatcher. -
字段概要
字段 -
方法概要
修饰符和类型方法说明static MethodMatcherintersection(MethodMatcher mm1, MethodMatcher mm2) Match all methods that both of the given MethodMatchers match.booleanIs this MethodMatcher dynamic, that is, must a final call be made on thematches(MethodInvocation)method at runtime even if the 2-arg matches method returnstrue?static booleanmatches(MethodMatcher mm, Method method, Class<?> targetClass, boolean hasIntroductions) Apply the given MethodMatcher to the given Method, supporting anIntroductionAwareMethodMatcher(if applicable).booleanChecking whether the given method matches.booleanmatches(MethodInvocation invocation) Check whether there a runtime (dynamic) match for this method, which must have matched statically.static MethodMatchernegate(MethodMatcher methodMatcher) Return a method matcher that represents the logical negation of the specified matcher instance.static MethodMatcherunion(MethodMatcher mm1, ClassFilter cf1, MethodMatcher mm2, ClassFilter cf2) Match all methods that either (or both) of the given MethodMatchers matches.static MethodMatcherunion(MethodMatcher mm1, MethodMatcher mm2) Match all methods that either (or both) of the given MethodMatchers matches.
-
字段详细资料
-
TRUE
Canonical instance that matches all methods.
-
-
方法详细资料
-
matches
Checking whether the given method matches.- 参数:
method- the candidate methodtargetClass- the target class- 返回:
- whether or not this method matches on application startup.
-
isRuntime
boolean isRuntime()Is this MethodMatcher dynamic, that is, must a final call be made on thematches(MethodInvocation)method at runtime even if the 2-arg matches method returnstrue?Can be invoked when an AOP proxy is created, and need not be invoked again before each method invocation,
- 返回:
- whether or not a runtime match via the 1-arg
matches(MethodInvocation)method is required if static matching passed
-
matches
Check whether there a runtime (dynamic) match for this method, which must have matched statically.This method is invoked only if the 2-arg matches method returns
truefor the given method and target class, and if theisRuntime()method returnstrue. Invoked immediately before potential running of the advice, after any advice earlier in the advice chain has run.- 参数:
invocation- runtime invocation contains the candidate method and target class, arguments to the method- 返回:
- whether there's a runtime match
- 另请参阅:
-
union
Match all methods that either (or both) of the given MethodMatchers matches.- 参数:
mm1- the first MethodMatchermm2- the second MethodMatcher- 返回:
- a distinct MethodMatcher that matches all methods that either of the given MethodMatchers matches
-
union
Match all methods that either (or both) of the given MethodMatchers matches.- 参数:
mm1- the first MethodMatchercf1- the corresponding ClassFilter for the first MethodMatchermm2- the second MethodMatchercf2- the corresponding ClassFilter for the second MethodMatcher- 返回:
- a distinct MethodMatcher that matches all methods that either of the given MethodMatchers matches
-
intersection
Match all methods that both of the given MethodMatchers match.- 参数:
mm1- the first MethodMatchermm2- the second MethodMatcher- 返回:
- a distinct MethodMatcher that matches all methods that both of the given MethodMatchers match
-
negate
Return a method matcher that represents the logical negation of the specified matcher instance.- 参数:
methodMatcher- theMethodMatcherto negate- 返回:
- a matcher that represents the logical negation of the specified matcher
- 从以下版本开始:
- 4.0
-
matches
static boolean matches(MethodMatcher mm, Method method, Class<?> targetClass, boolean hasIntroductions) Apply the given MethodMatcher to the given Method, supporting anIntroductionAwareMethodMatcher(if applicable).- 参数:
mm- the MethodMatcher to apply (may be an IntroductionAwareMethodMatcher)method- the candidate methodtargetClass- the target classhasIntroductions-trueif the object on whose behalf we are asking is the subject on one or more introductions;falseotherwise- 返回:
- whether or not this method matches statically
-