org.springframework.messaging.handler.invocation

Class InvocableHandlerMethod

    • Constructor Detail

      • InvocableHandlerMethod

        public InvocableHandlerMethod(HandlerMethod handlerMethod)
        Create an instance from a HandlerMethod.
      • InvocableHandlerMethod

        public InvocableHandlerMethod(java.lang.Object bean,
                                      java.lang.reflect.Method method)
        Create an instance from a bean instance and a method.
      • InvocableHandlerMethod

        public InvocableHandlerMethod(java.lang.Object bean,
                                      java.lang.String methodName,
                                      java.lang.Class<?>... parameterTypes)
                               throws java.lang.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:
        java.lang.NoSuchMethodException - when the method cannot be found
    • Method Detail

      • 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

        @Nullable
        public java.lang.Object invoke(Message<?> message,
                                                 java.lang.Object... providedArgs)
                                          throws java.lang.Exception
        Invoke the method after resolving its argument values in the context of the given message.

        Argument values are commonly resolved through HandlerMethodArgumentResolvers. The providedArgs parameter however may supply argument values to be used directly, i.e. without argument resolution.

        Parameters:
        message - the current message being processed
        providedArgs - "given" arguments matched by type, not resolved
        Returns:
        the raw value returned by the invoked method
        Throws:
        java.lang.Exception - raised if no suitable argument resolver can be found, or if the method raised an exception
      • doInvoke

        @Nullable
        protected java.lang.Object doInvoke(java.lang.Object... args)
                                               throws java.lang.Exception
        Invoke the handler method with the given argument values.
        Throws:
        java.lang.Exception
      • getDetailedErrorMessage

        protected java.lang.String getDetailedErrorMessage(java.lang.String text)
        Adds HandlerMethod details such as the bean type and method signature to the message.
        Parameters:
        text - error message to append the HandlerMethod details to