类 ReflectiveMethodResolver
- java.lang.Object
- org.springframework.expression.spel.support.ReflectiveMethodResolver
- 所有已实现的接口:
MethodResolver
- 直接已知子类:
DataBindingMethodResolver
public class ReflectiveMethodResolver extends Object implements MethodResolver
Reflection-basedMethodResolver
used by default inStandardEvaluationContext
unless explicit method resolvers have been specified.- 从以下版本开始:
- 3.0
- 作者:
- Andy Clement, Juergen Hoeller, Chris Beams
- 另请参阅:
StandardEvaluationContext.addMethodResolver(MethodResolver)
构造器概要
构造器 构造器 说明 ReflectiveMethodResolver()
ReflectiveMethodResolver(boolean useDistance)
This constructor allows the ReflectiveMethodResolver to be configured such that it will use a distance computation to check which is the better of two close matches (when there are multiple matches).
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Method[]
getMethods(Class<?> type)
Return the set of methods for this type.protected boolean
isCandidateForInvocation(Method method, Class<?> targetClass)
Determine whether the givenMethod
is a candidate for method resolution on an instance of the given target class.void
registerMethodFilter(Class<?> type, MethodFilter filter)
Register a filter for methods on the given type.MethodExecutor
resolve(EvaluationContext context, Object targetObject, String name, List<TypeDescriptor> argumentTypes)
Locate a method on a type.
构造器详细资料
ReflectiveMethodResolver
public ReflectiveMethodResolver()
ReflectiveMethodResolver
public ReflectiveMethodResolver(boolean useDistance)
This constructor allows the ReflectiveMethodResolver to be configured such that it will use a distance computation to check which is the better of two close matches (when there are multiple matches). Using the distance computation is intended to ensure matches are more closely representative of what a Java compiler would do when taking into account boxing/unboxing and whether the method candidates are declared to handle a supertype of the type (of the argument) being passed in.- 参数:
useDistance
-true
if distance computation should be used when calculating matches;false
otherwise
方法详细资料
registerMethodFilter
public void registerMethodFilter(Class<?> type, MethodFilter filter)
Register a filter for methods on the given type.- 参数:
type
- the type to filter onfilter
- the corresponding method filter, ornull
to clear any filter for the given type
resolve
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name, List<TypeDescriptor> argumentTypes) throws AccessException
Locate a method on a type. There are three kinds of match that might occur:- an exact match where the types of the arguments match the types of the constructor
- an in-exact match where the types we are looking for are subtypes of those defined on the constructor
- a match where we are able to convert the arguments into those expected by the constructor, according to the registered type converter
- 指定者:
resolve
在接口中MethodResolver
- 参数:
context
- the current evaluation contexttargetObject
- the object upon which the method is being calledargumentTypes
- the arguments that the constructor must be able to handle- 返回:
- a MethodExecutor that can invoke the method, or null if the method cannot be found
- 抛出:
AccessException
getMethods
protected Method[] getMethods(Class<?> type)
Return the set of methods for this type. The default implementation returns the result ofClass.getMethods()
for the giventype
, but subclasses may override in order to alter the results, e.g. specifying static methods declared elsewhere.- 参数:
type
- the class for which to return the methods- 从以下版本开始:
- 3.1.1
isCandidateForInvocation
protected boolean isCandidateForInvocation(Method method, Class<?> targetClass)
Determine whether the givenMethod
is a candidate for method resolution on an instance of the given target class.The default implementation considers any method as a candidate, even for static methods sand non-user-declared methods on the
Object
base class.- 参数:
method
- the Method to evaluatetargetClass
- the concrete target class that is being introspected- 从以下版本开始:
- 4.3.15