接口 MethodMatcher
- 所有已知子接口:
IntroductionAwareMethodMatcher
- 所有已知实现类:
AbstractRegexpMethodPointcut,AnnotationMethodMatcher,AspectJExpressionPointcut,ControlFlowPointcut,DynamicMethodMatcher,DynamicMethodMatcherPointcut,JdkRegexpMethodPointcut,NameMatchMethodPointcut,StaticMethodMatcher,StaticMethodMatcherPointcut,StaticMethodMatcherPointcutAdvisor
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.
Concrete implementations of this interface typically should provide proper
implementations of Object.equals(Object) and Object.hashCode()
in order to allow the matcher to be used in caching scenarios — for
example, in proxies generated by CGLIB.
- 从以下版本开始:
- 3.0
- 作者:
- Rod Johnson, TODAY 2019-10-20 22:43
- 另请参阅:
-
字段概要
字段 -
方法概要
修饰符和类型方法说明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?booleanChecking whether the given method matches.booleanmatches(MethodInvocation invocation) Check whether there a runtime (dynamic) match for this method, which must have matched statically.
-
字段详细资料
-
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
- 另请参阅:
-