public class InvocableHandlerMethod extends HandlerMethod
HandlerMethod
that invokes the underlying method with
argument values resolved from the current HTTP request through a list of
HandlerMethodArgumentResolver
.HandlerMethod.HandlerMethodParameter
logger
Modifier | Constructor and Description |
---|---|
|
InvocableHandlerMethod(HandlerMethod handlerMethod)
Create an instance from a
HandlerMethod . |
|
InvocableHandlerMethod(Object bean,
Method method)
Create an instance from a bean instance and a method.
|
protected |
InvocableHandlerMethod(Object bean,
Method method,
MessageSource messageSource)
Variant of
InvocableHandlerMethod(Object, Method) that
also accepts a MessageSource , for use in sub-classes. |
|
InvocableHandlerMethod(Object bean,
String methodName,
Class<?>... parameterTypes)
Construct a new handler method with the given bean instance, method name and parameters.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
doInvoke(Object... args)
Invoke the handler method with the given argument values.
|
protected Object[] |
getMethodArgumentValues(NativeWebRequest request,
ModelAndViewContainer mavContainer,
Object... providedArgs)
Get the method argument values for the current request, checking the provided
argument values and falling back to the configured argument resolvers.
|
Object |
invokeForRequest(NativeWebRequest request,
ModelAndViewContainer mavContainer,
Object... providedArgs)
Invoke the method after resolving its argument values in the context of the given request.
|
void |
setDataBinderFactory(WebDataBinderFactory dataBinderFactory)
Set the
WebDataBinderFactory to be passed to argument resolvers allowing them
to create a WebDataBinder for data binding and type conversion purposes. |
void |
setHandlerMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
Set
HandlerMethodArgumentResolvers
to use for resolving method argument values. |
void |
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer for resolving parameter names when needed
(e.g.
|
assertTargetBean, createWithResolvedBean, equals, findProvidedArgument, formatArgumentError, formatInvokeError, getBean, getBeanType, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getResolvedFromHandlerMethod, getResponseStatus, getResponseStatusReason, getReturnType, getReturnValueType, getShortLogMessage, hashCode, hasMethodAnnotation, isVoid, toString
public InvocableHandlerMethod(HandlerMethod handlerMethod)
HandlerMethod
.public InvocableHandlerMethod(Object bean, Method method)
protected InvocableHandlerMethod(Object bean, Method method, @Nullable MessageSource messageSource)
InvocableHandlerMethod(Object, Method)
that
also accepts a MessageSource
, for use in sub-classes.public InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException
bean
- the object beanmethodName
- the method nameparameterTypes
- the method parameter typesNoSuchMethodException
- when the method cannot be foundpublic void setHandlerMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
HandlerMethodArgumentResolvers
to use for resolving method argument values.public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Default is a DefaultParameterNameDiscoverer
.
public void setDataBinderFactory(WebDataBinderFactory dataBinderFactory)
WebDataBinderFactory
to be passed to argument resolvers allowing them
to create a WebDataBinder
for data binding and type conversion purposes.@Nullable public Object invokeForRequest(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception
Argument values are commonly resolved through
HandlerMethodArgumentResolvers
.
The providedArgs
parameter however may supply argument values to be used directly,
i.e. without argument resolution. Examples of provided argument values include a
WebDataBinder
, a SessionStatus
, or a thrown exception instance.
Provided argument values are checked before argument resolvers.
Delegates to getMethodArgumentValues(org.springframework.web.context.request.NativeWebRequest, org.springframework.web.method.support.ModelAndViewContainer, java.lang.Object...)
and calls doInvoke(java.lang.Object...)
with the
resolved arguments.
request
- the current requestmavContainer
- the ModelAndViewContainer for this requestprovidedArgs
- "given" arguments matched by type, not resolvedException
- raised if no suitable argument resolver can be found,
or if the method raised an exceptiongetMethodArgumentValues(org.springframework.web.context.request.NativeWebRequest, org.springframework.web.method.support.ModelAndViewContainer, java.lang.Object...)
,
doInvoke(java.lang.Object...)
protected Object[] getMethodArgumentValues(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception
The resulting array will be passed into doInvoke(java.lang.Object...)
.
Exception