Class InvocableHandlerMethod
- Direct Known Subclasses:
- ServletInvocableHandlerMethod
HandlerMethod that invokes the underlying method with
argument values resolved from the current HTTP request through a list of
HandlerMethodArgumentResolver.- Since:
- 3.1
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze
- 
Nested Class SummaryNested classes/interfaces inherited from class AnnotatedMethodAnnotatedMethod.AnnotatedMethodParameter
- 
Field SummaryFields inherited from class HandlerMethodlogger
- 
Constructor SummaryConstructorsModifierConstructorDescriptionInvocableHandlerMethod(Object bean, Method method) Create an instance from a bean instance and a method.protectedInvocableHandlerMethod(Object bean, Method method, @Nullable MessageSource messageSource) Variant ofInvocableHandlerMethod(Object, Method)that also accepts aMessageSource, for use in subclasses.InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) Construct a new handler method with the given bean instance, method name and parameters.InvocableHandlerMethod(HandlerMethod handlerMethod) Create an instance from aHandlerMethod.
- 
Method SummaryModifier and TypeMethodDescriptionInvoke the handler method with the given argument values.getMethodArgumentValues(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, @Nullable Object... providedArgs) Get the method argument values for the current request, checking the provided argument values and falling back to the configured argument resolvers.invokeForRequest(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, @Nullable Object... providedArgs) Invoke the method after resolving its argument values in the context of the given request.protected ObjectinvokeSuspendingFunction(Method method, Object target, @Nullable Object[] args) Invoke the given Kotlin coroutine suspended function.voidsetDataBinderFactory(WebDataBinderFactory dataBinderFactory) Set theWebDataBinderFactoryto be passed to argument resolvers allowing them to create aWebDataBinderfor data binding and type conversion purposes.voidsetHandlerMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers) SetHandlerMethodArgumentResolversto use for resolving method argument values.voidsetMethodValidator(@Nullable MethodValidator methodValidator) Set theMethodValidatorto perform method validation with if the controller methodHandlerMethod.shouldValidateArguments()orHandlerMethod.shouldValidateReturnValue().voidsetParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) Set the ParameterNameDiscoverer for resolving parameter names when needed (for example, default request attribute name).Methods inherited from class HandlerMethodassertTargetBean, createWithResolvedBean, createWithValidateFlags, equals, formatInvokeError, getBean, getBeanType, getContainingClass, getResolvedFromHandlerMethod, getResponseStatus, getResponseStatusReason, getShortLogMessage, hashCode, shouldValidateArguments, shouldValidateReturnValue, toStringMethods inherited from class AnnotatedMethodfindProvidedArgument, formatArgumentError, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getReturnType, getReturnValueType, hasMethodAnnotation, isVoid
- 
Constructor Details- 
InvocableHandlerMethodCreate an instance from aHandlerMethod.
- 
InvocableHandlerMethod
- 
InvocableHandlerMethodVariant ofInvocableHandlerMethod(Object, Method)that also accepts aMessageSource, for use in subclasses.- Since:
- 5.3.10
 
- 
InvocableHandlerMethodpublic InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException Construct a new handler method with the given bean instance, method name and parameters.- Parameters:
- bean- the object bean
- methodName- the method name
- parameterTypes- the method parameter types
- Throws:
- NoSuchMethodException- when the method cannot be found
 
 
- 
- 
Method Details- 
setHandlerMethodArgumentResolverspublic void setHandlerMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers) SetHandlerMethodArgumentResolversto use for resolving method argument values.
- 
setParameterNameDiscovererSet the ParameterNameDiscoverer for resolving parameter names when needed (for example, default request attribute name).Default is a DefaultParameterNameDiscoverer.
- 
setDataBinderFactorySet theWebDataBinderFactoryto be passed to argument resolvers allowing them to create aWebDataBinderfor data binding and type conversion purposes.
- 
setMethodValidatorSet theMethodValidatorto perform method validation with if the controller methodHandlerMethod.shouldValidateArguments()orHandlerMethod.shouldValidateReturnValue().- Since:
- 6.1
 
- 
invokeForRequestpublic @Nullable Object invokeForRequest(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, @Nullable Object... providedArgs) throws Exception Invoke the method after resolving its argument values in the context of the given request.Argument values are commonly resolved through HandlerMethodArgumentResolvers. TheprovidedArgsparameter however may supply argument values to be used directly, i.e. without argument resolution. Examples of provided argument values include aWebDataBinder, aSessionStatus, or a thrown exception instance. Provided argument values are checked before argument resolvers.Delegates to getMethodArgumentValues(NativeWebRequest, ModelAndViewContainer, Object...)and callsdoInvoke(Object...)with the resolved arguments.- Parameters:
- request- the current request
- mavContainer- the ModelAndViewContainer for this request
- providedArgs- "given" arguments matched by type, not resolved
- Returns:
- the raw value returned by the invoked method
- Throws:
- Exception- raised if no suitable argument resolver can be found, or if the method raised an exception
- See Also:
 
- 
getMethodArgumentValuesprotected @Nullable Object[] getMethodArgumentValues(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, @Nullable Object... providedArgs) throws Exception Get the method argument values for the current request, checking the provided argument values and falling back to the configured argument resolvers.The resulting array will be passed into doInvoke(Object...).- Throws:
- Exception
- Since:
- 5.1.2
 
- 
doInvoke
- 
invokeSuspendingFunctionInvoke the given Kotlin coroutine suspended function.The default implementation invokes CoroutinesUtils.invokeSuspendingFunction(Method, Object, Object...), but subclasses can override this method to useCoroutinesUtils.invokeSuspendingFunction(kotlin.coroutines.CoroutineContext, Method, Object, Object...)instead.- Since:
- 6.0
 
 
-