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.
        bean - the object bean
        methodName - the method name
        parameterTypes - the method parameter types
        java.lang.NoSuchMethodException - when the method cannot be found
    • Method Detail

      • setDataBinderFactory

        public 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.
        dataBinderFactory - the data binder factory.
      • 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.

      • invokeForRequest

        public java.lang.Object invokeForRequest(NativeWebRequest request,
                                                           ModelAndViewContainer mavContainer,
                                                           java.lang.Object... providedArgs)
                                                    throws java.lang.Exception
        Invoke the method after resolving its argument values in the context of the given request.

        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.

        request - the current request
        mavContainer - the ModelAndViewContainer for this request
        providedArgs - "given" arguments matched by type, not resolved
        the raw value returned by the invoked method
        java.lang.Exception - raised if no suitable argument resolver can be found, or if the method raised an exception
      • doInvoke

        protected java.lang.Object doInvoke(java.lang.Object... args)
                                     throws java.lang.Exception
        Invoke the handler method with the given argument values.