org.springframework.messaging.handler.invocation

## Class InvocableHandlerMethod

- java.lang.Object
- - org.springframework.messaging.handler.HandlerMethod
  - - org.springframework.messaging.handler.invocation.InvocableHandlerMethod

-     public class InvocableHandlerMethod
      extends HandlerMethod

  Invokes the handler method for a given message after resolving its method argument values through registered `HandlerMethodArgumentResolver`s.

  Use `setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite)` to customize the list of argument resolvers.

  Since:
    4.0
  Author:
    Rossen Stoyanchev

- - ### Field Summary

    - ### Fields inherited from class org.springframework.messaging.handler.HandlerMethod

      `logger`

  - ### Constructor Summary

    Constructors
    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.
    `InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes)` Construct a new handler method with the given bean instance, method name and parameters.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `getDetailedErrorMessage(String message)` Adds HandlerMethod details such as the controller type and method signature to the given error message.
    `Object` | `invoke(Message<?> message, Object... providedArgs)` Invoke the method with the given message.
    `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.

    - ### Methods inherited from class org.springframework.messaging.handler.HandlerMethod

      `createWithResolvedBean, equals, getBean, getBeanType, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getReturnType, getReturnValueType, hashCode, isVoid, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### InvocableHandlerMethod

          public InvocableHandlerMethod(HandlerMethod handlerMethod)

      Create an instance from a `HandlerMethod`.

    - #### InvocableHandlerMethod

          public InvocableHandlerMethod(Object bean,
                                        Method method)

      Create an instance from a bean instance and a method.

    - #### InvocableHandlerMethod

          public 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 Detail

    - #### setMessageMethodArgumentResolvers

          public void setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)

      Set `HandlerMethodArgumentResolver`s to use to use for resolving method argument values.

    - #### setParameterNameDiscoverer

          public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)

      Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g. default request attribute name).

      Default is a `DefaultParameterNameDiscoverer`.

    - #### invoke

          public final Object invoke(Message<?> message,
                                     Object... providedArgs)
                              throws Exception

      Invoke the method with the given message.
      Throws:
        `Exception` - raised if no suitable argument resolver can be found, or the method raised an exception

    - #### getDetailedErrorMessage

          protected String getDetailedErrorMessage(String message)

      Adds HandlerMethod details such as the controller type and method signature to the given error message.
      Parameters:
        `message` - error message to append the HandlerMethod details to