Class ReflectiveMethodResolver
java.lang.Object
org.springframework.expression.spel.support.ReflectiveMethodResolver
- All Implemented Interfaces:
- MethodResolver
- Direct Known Subclasses:
- DataBindingMethodResolver
Reflection-based 
MethodResolver used by default in StandardEvaluationContext
 unless explicit method resolvers have been specified.- Since:
- 3.0
- Author:
- Andy Clement, Juergen Hoeller, Chris Beams, Sam Brannen
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionReflectiveMethodResolver(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).
- 
Method SummaryModifier and TypeMethodDescriptionprotected Method[]getMethods(Class<?> type) Return the set of methods for this type.protected booleanisCandidateForInvocation(Method method, Class<?> targetClass) Determine whether the givenMethodis a candidate for method resolution on an instance of the given target class.voidregisterMethodFilter(Class<?> type, MethodFilter filter) Register a filter for methods on the given type.resolve(EvaluationContext context, Object targetObject, String name, List<TypeDescriptor> argumentTypes) Locate a method on the type.
- 
Constructor Details- 
ReflectiveMethodResolverpublic ReflectiveMethodResolver()
- 
ReflectiveMethodResolverpublic 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.- Parameters:
- useDistance-- trueif distance computation should be used when calculating matches;- falseotherwise
 
 
- 
- 
Method Details- 
registerMethodFilterRegister a filter for methods on the given type.- Parameters:
- type- the type to filter on
- filter- the corresponding method filter, or- nullto clear any filter for the given type
 
- 
resolve@Nullable public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name, List<TypeDescriptor> argumentTypes) throws AccessException Locate a method on the type.There are three kinds of matches that might occur: - An exact match where the types of the arguments match the types of the method.
- An inexact match where the types we are looking for are subtypes of those defined on the method.
- A match where we are able to convert the arguments into those expected by the method, according to the registered type converter.
 - Specified by:
- resolvein interface- MethodResolver
- Parameters:
- context- the current evaluation context
- targetObject- the object upon which the method is being called
- name- the name of the method
- argumentTypes- the types of arguments that the method must be able to handle
- Returns:
- a MethodExecutorthat can invoke the method, ornullif the method cannot be found
- Throws:
- AccessException
 
- 
getMethodsReturn 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, for example, specifying static methods declared elsewhere.- Parameters:
- type- the class for which to return the methods
- Since:
- 3.1.1
 
- 
isCandidateForInvocationDetermine whether the givenMethodis 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 and non-user-declared methods on the Objectbase class.- Parameters:
- method- the Method to evaluate
- targetClass- the concrete target class that is being introspected
- Since:
- 4.3.15
 
 
-