public class InvocableHandlerMethod extends HandlerMethod
HandlerMethodArgumentResolver
s.
Use setMessageMethodArgumentResolvers(org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolverComposite)
to customize the list of argument resolvers.
Modifier and Type | Class and Description |
---|---|
private class |
InvocableHandlerMethod.AsyncResultMethodParameter |
HandlerMethod.HandlerMethodParameter
Modifier and Type | Field and Description |
---|---|
private HandlerMethodArgumentResolverComposite |
argumentResolvers |
private ParameterNameDiscoverer |
parameterNameDiscoverer |
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 |
---|---|
private void |
assertTargetBean(java.lang.reflect.Method method,
java.lang.Object targetBean,
java.lang.Object[] args)
Assert that the target bean class is an instance of the class where the given
method is declared.
|
protected java.lang.Object |
doInvoke(java.lang.Object... args)
Invoke the handler method with the given argument values.
|
private java.lang.String |
getArgumentResolutionErrorMessage(java.lang.String text,
int index) |
(package private) MethodParameter |
getAsyncReturnValueType(java.lang.Object returnValue) |
protected java.lang.String |
getDetailedErrorMessage(java.lang.String text)
Adds HandlerMethod details such as the bean type and method signature to the message.
|
private java.lang.String |
getInvocationErrorMessage(java.lang.String text,
java.lang.Object[] resolvedArgs) |
private java.lang.Object[] |
getMethodArgumentValues(Message<?> message,
java.lang.Object... providedArgs)
Get the method argument values for the current request.
|
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.
|
private java.lang.Object |
resolveProvidedArgument(MethodParameter parameter,
java.lang.Object... providedArgs)
Attempt to resolve a method parameter from the list of provided argument values.
|
void |
setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
Set
HandlerMethodArgumentResolver s to use to use for resolving method argument values. |
void |
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer for resolving parameter names when needed
(e.g.
|
createWithResolvedBean, equals, getBean, getBeanType, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getResolvedFromHandlerMethod, getReturnType, getReturnValueType, getShortLogMessage, hashCode, hasMethodAnnotation, isVoid, toString
private HandlerMethodArgumentResolverComposite argumentResolvers
private ParameterNameDiscoverer parameterNameDiscoverer
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)
HandlerMethodArgumentResolver
s to use to use for resolving method argument values.public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Default is a DefaultParameterNameDiscoverer
.
public java.lang.Object invoke(Message<?> message, java.lang.Object... providedArgs) throws java.lang.Exception
Argument values are commonly resolved through HandlerMethodArgumentResolver
s.
The providedArgs
parameter however may supply argument values to be used directly,
i.e. without argument resolution.
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 exceptionprivate java.lang.Object[] getMethodArgumentValues(Message<?> message, java.lang.Object... providedArgs) throws java.lang.Exception
java.lang.Exception
private java.lang.String getArgumentResolutionErrorMessage(java.lang.String text, int index)
private java.lang.Object resolveProvidedArgument(MethodParameter parameter, java.lang.Object... providedArgs)
protected java.lang.Object doInvoke(java.lang.Object... args) throws java.lang.Exception
java.lang.Exception
private void assertTargetBean(java.lang.reflect.Method method, java.lang.Object targetBean, java.lang.Object[] args)
private java.lang.String getInvocationErrorMessage(java.lang.String text, java.lang.Object[] resolvedArgs)
protected java.lang.String getDetailedErrorMessage(java.lang.String text)
text
- error message to append the HandlerMethod details toMethodParameter getAsyncReturnValueType(java.lang.Object returnValue)