Class ArgumentConvertingMethodInvoker
- Direct Known Subclasses:
MethodInvokingBean
,MethodInvokingJobDetailFactoryBean
,MethodInvokingRunnable
MethodInvoker
that tries to convert the given
arguments for the actual target method via a TypeConverter
.
Supports flexible argument conversions, in particular for invoking a specific overloaded method.
- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
-
AbstractNestablePropertyAccessor.convertIfNecessary(java.lang.String, java.lang.Object, java.lang.Object, java.lang.Class<?>, org.springframework.core.convert.TypeDescriptor)
-
Field Summary
Fields inherited from class org.springframework.util.MethodInvoker
targetClass
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Method
doFindMatchingMethod
(Object[] arguments) Actually find a method with matching parameter type, i.e.protected Method
This implementation looks for a method with matching parameter types.protected TypeConverter
Obtain the default TypeConverter for this method invoker.Return the TypeConverter used for argument type conversion.void
registerCustomEditor
(Class<?> requiredType, PropertyEditor propertyEditor) Register the given custom property editor for all properties of the given type.void
setTypeConverter
(TypeConverter typeConverter) Set a TypeConverter to use for argument type conversion.Methods inherited from class org.springframework.util.MethodInvoker
getArguments, getPreparedMethod, getTargetClass, getTargetMethod, getTargetObject, getTypeDifferenceWeight, invoke, isPrepared, prepare, resolveClassName, setArguments, setStaticMethod, setTargetClass, setTargetMethod, setTargetObject
-
Constructor Details
-
ArgumentConvertingMethodInvoker
public ArgumentConvertingMethodInvoker()
-
-
Method Details
-
setTypeConverter
Set a TypeConverter to use for argument type conversion.Default is a
SimpleTypeConverter
. Can be overridden with any TypeConverter implementation, typically a pre-configured SimpleTypeConverter or a BeanWrapperImpl instance.- See Also:
-
getTypeConverter
Return the TypeConverter used for argument type conversion.Can be cast to
PropertyEditorRegistry
if direct access to the underlying PropertyEditors is desired (provided that the present TypeConverter actually implements the PropertyEditorRegistry interface). -
getDefaultTypeConverter
Obtain the default TypeConverter for this method invoker.Called if no explicit TypeConverter has been specified. The default implementation builds a
SimpleTypeConverter
. Can be overridden in subclasses. -
registerCustomEditor
Register the given custom property editor for all properties of the given type.Typically used in conjunction with the default
SimpleTypeConverter
; will work with any TypeConverter that implements the PropertyEditorRegistry interface as well.- Parameters:
requiredType
- type of the propertypropertyEditor
- editor to register- See Also:
-
findMatchingMethod
This implementation looks for a method with matching parameter types.- Overrides:
findMatchingMethod
in classMethodInvoker
- Returns:
- a matching method, or
null
if none - See Also:
-
doFindMatchingMethod
Actually find a method with matching parameter type, i.e. where each argument value is assignable to the corresponding parameter type.- Parameters:
arguments
- the argument values to match against method parameters- Returns:
- a matching method, or
null
if none
-