public class ServletInvocableHandlerMethod extends InvocableHandlerMethod
InvocableHandlerMethod
with the ability to handle return
values through a registered HandlerMethodReturnValueHandler
and
also supports setting the response status based on a method-level
@ResponseStatus
annotation.
A null
return value (including void) may be interpreted as the
end of request processing in combination with a @ResponseStatus
annotation, a not-modified check condition
(see ServletWebRequest.checkNotModified(long)
), or
a method argument that provides access to the response stream.
Modifier and Type | Class and Description |
---|---|
private class |
ServletInvocableHandlerMethod.ConcurrentResultHandlerMethod
A nested subclass of
ServletInvocableHandlerMethod that uses a
simple Callable instead of the original controller as the handler in
order to return the fixed (concurrent) result value given to it. |
private class |
ServletInvocableHandlerMethod.ConcurrentResultMethodParameter
MethodParameter subclass based on the actual return value type or if
that's null falling back on the generic type within the declared async
return type, e.g.
|
HandlerMethod.HandlerMethodParameter
Modifier and Type | Field and Description |
---|---|
private static java.lang.reflect.Method |
CALLABLE_METHOD |
private java.lang.String |
responseReason |
private HttpStatus |
responseStatus |
private HandlerMethodReturnValueHandlerComposite |
returnValueHandlers |
logger
Constructor and Description |
---|
ServletInvocableHandlerMethod(HandlerMethod handlerMethod)
Create an instance from a
HandlerMethod . |
ServletInvocableHandlerMethod(java.lang.Object handler,
java.lang.reflect.Method method)
Creates an instance from the given handler and method.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
getReturnValueHandlingErrorMessage(java.lang.String message,
java.lang.Object returnValue) |
private boolean |
hasResponseStatus()
Does this method have the response status instruction?
|
private void |
initResponseStatus() |
void |
invokeAndHandle(ServletWebRequest webRequest,
ModelAndViewContainer mavContainer,
java.lang.Object... providedArgs)
Invokes the method and handles the return value through one of the
configured
HandlerMethodReturnValueHandler s. |
private boolean |
isRequestNotModified(ServletWebRequest webRequest)
Does the given request qualify as "not modified"?
|
void |
setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers)
Register
HandlerMethodReturnValueHandler instances to use to
handle return values. |
private void |
setResponseStatus(ServletWebRequest webRequest)
Set the response status according to the
ResponseStatus annotation. |
(package private) ServletInvocableHandlerMethod |
wrapConcurrentResult(java.lang.Object result)
Create a nested ServletInvocableHandlerMethod subclass that returns the
the given value (or raises an Exception if the value is one) rather than
actually invoking the controller method.
|
doInvoke, getDetailedErrorMessage, invokeForRequest, setDataBinderFactory, setHandlerMethodArgumentResolvers, setParameterNameDiscoverer
createWithResolvedBean, equals, getBean, getBeanType, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getResolvedFromHandlerMethod, getReturnType, getReturnValueType, hashCode, isVoid, toString
private static final java.lang.reflect.Method CALLABLE_METHOD
private HttpStatus responseStatus
private java.lang.String responseReason
private HandlerMethodReturnValueHandlerComposite returnValueHandlers
public ServletInvocableHandlerMethod(java.lang.Object handler, java.lang.reflect.Method method)
public ServletInvocableHandlerMethod(HandlerMethod handlerMethod)
HandlerMethod
.private void initResponseStatus()
public void setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers)
HandlerMethodReturnValueHandler
instances to use to
handle return values.public void invokeAndHandle(ServletWebRequest webRequest, ModelAndViewContainer mavContainer, java.lang.Object... providedArgs) throws java.lang.Exception
HandlerMethodReturnValueHandler
s.webRequest
- the current requestmavContainer
- the ModelAndViewContainer for this requestprovidedArgs
- "given" arguments matched by type (not resolved)java.lang.Exception
private void setResponseStatus(ServletWebRequest webRequest) throws java.io.IOException
ResponseStatus
annotation.java.io.IOException
private boolean isRequestNotModified(ServletWebRequest webRequest)
private boolean hasResponseStatus()
private java.lang.String getReturnValueHandlingErrorMessage(java.lang.String message, java.lang.Object returnValue)
ServletInvocableHandlerMethod wrapConcurrentResult(java.lang.Object result)