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
defaultLogger, logger
Constructor and Description |
---|
InvocableHandlerMethod(HandlerMethod handlerMethod)
Create an instance from a
HandlerMethod . |
InvocableHandlerMethod(java.lang.Object bean,
java.lang.reflect.Method method)
Create an instance from a bean instance and a method.
|
InvocableHandlerMethod(java.lang.Object bean,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Construct a new handler method with the given bean instance, method name and parameters.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
doInvoke(java.lang.Object... args)
Invoke the handler method with the given argument values.
|
protected java.lang.Object[] |
getMethodArgumentValues(Message<?> message,
java.lang.Object... providedArgs)
Get the method argument values for the current message, checking the provided
argument values and falling back to the configured argument resolvers.
|
java.lang.Object |
invoke(Message<?> message,
java.lang.Object... providedArgs)
Invoke the method after resolving its argument values in the context of the given message.
|
void |
setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
Set
HandlerMethodArgumentResolvers to use 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, getLogger, getMethod, getMethodAnnotation, getMethodParameters, getResolvedFromHandlerMethod, getReturnType, getReturnValueType, getShortLogMessage, hashCode, hasMethodAnnotation, isVoid, setLogger, toString
public InvocableHandlerMethod(HandlerMethod handlerMethod)
HandlerMethod
.public InvocableHandlerMethod(java.lang.Object bean, java.lang.reflect.Method method)
public InvocableHandlerMethod(java.lang.Object bean, java.lang.String methodName, java.lang.Class<?>... parameterTypes) throws java.lang.NoSuchMethodException
bean
- the object beanmethodName
- the method nameparameterTypes
- the method parameter typesjava.lang.NoSuchMethodException
- when the method cannot be foundpublic void setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
HandlerMethodArgumentResolvers
to use to use for resolving method argument values.public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Default is a DefaultParameterNameDiscoverer
.
@Nullable public java.lang.Object invoke(Message<?> message, java.lang.Object... providedArgs) throws java.lang.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.
Delegates to getMethodArgumentValues(org.springframework.messaging.Message<?>, java.lang.Object...)
and calls doInvoke(java.lang.Object...)
with the
resolved arguments.
message
- the current message being processedprovidedArgs
- "given" arguments matched by type, not resolvedjava.lang.Exception
- raised if no suitable argument resolver can be found,
or if the method raised an exceptiongetMethodArgumentValues(org.springframework.messaging.Message<?>, java.lang.Object...)
,
doInvoke(java.lang.Object...)
protected java.lang.Object[] getMethodArgumentValues(Message<?> message, java.lang.Object... providedArgs) throws java.lang.Exception
The resulting array will be passed into doInvoke(java.lang.Object...)
.
java.lang.Exception
@Nullable protected java.lang.Object doInvoke(java.lang.Object... args) throws java.lang.Exception
java.lang.Exception