org.springframework.web.servlet.mvc.method.annotation
Class ServletInvocableHandlerMethod

java.lang.Object
  extended by org.springframework.web.method.HandlerMethod
      extended by org.springframework.web.method.support.InvocableHandlerMethod
          extended by org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod

public class ServletInvocableHandlerMethod
extends InvocableHandlerMethod

Extends InvocableHandlerMethod with the ability to handle the value returned from the method through a registered HandlerMethodArgumentResolver that supports the given return value type. Return value handling may include writing to the response or updating the ModelAndViewContainer structure.

If the underlying method has a ResponseStatus instruction, the status on the response is set accordingly after the method is invoked but before the return value is handled.

Since:
3.1
Author:
Rossen Stoyanchev
See Also:
invokeAndHandle(NativeWebRequest, ModelAndViewContainer, Object...)

Field Summary
 
Fields inherited from class org.springframework.web.method.HandlerMethod
logger
 
Constructor Summary
ServletInvocableHandlerMethod(Object handler, Method method)
          Creates a ServletInvocableHandlerMethod instance with the given bean and method.
 
Method Summary
 void invokeAndHandle(NativeWebRequest request, ModelAndViewContainer mavContainer, Object... providedArgs)
          Invokes the method and handles the return value through a registered HandlerMethodReturnValueHandler.
 void setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers)
           
 
Methods inherited from class org.springframework.web.method.support.InvocableHandlerMethod
getDetailedErrorMessage, invokeForRequest, setDataBinderFactory, setHandlerMethodArgumentResolvers, setParameterNameDiscoverer
 
Methods inherited from class org.springframework.web.method.HandlerMethod
createWithResolvedBean, equals, getBean, getBeanType, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getReturnType, hashCode, isVoid, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServletInvocableHandlerMethod

public ServletInvocableHandlerMethod(Object handler,
                                     Method method)
Creates a ServletInvocableHandlerMethod instance with the given bean and method.

Parameters:
handler - the object handler
method - the method
Method Detail

setHandlerMethodReturnValueHandlers

public void setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers)

invokeAndHandle

public final void invokeAndHandle(NativeWebRequest request,
                                  ModelAndViewContainer mavContainer,
                                  Object... providedArgs)
                           throws Exception
Invokes the method and handles the return value through a registered HandlerMethodReturnValueHandler.

Return value handling may be skipped entirely when the method returns null (also possibly due to a void return type) and one of the following additional conditions is true:

After the return value is handled, callers of this method can use the ModelAndViewContainer to gain access to model attributes, view selection choices, and to check if view resolution is even needed.

Parameters:
request - the current request
mavContainer - the ModelAndViewContainer for the current request
providedArgs - argument values to try to use without the need for view resolution
Throws:
Exception