public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodReturnValueHandler
HandlerMethodReturnValueHandler
that handles return values that
represent asynchronous computation. Such handlers need to be invoked with
precedence over other handlers that might otherwise match the return value
type: e.g. a method that returns a Promise type that is also annotated with
@ResponseBody
.
In HandlerMethodReturnValueHandler.handleReturnValue(java.lang.Object, org.springframework.core.MethodParameter, org.springframework.web.method.support.ModelAndViewContainer, org.springframework.web.context.request.NativeWebRequest)
, implementations of this class should create
a DeferredResult
or
adapt to it and then invoke WebAsyncManager
to start async processing.
For example:
DeferredResult> deferredResult = (DeferredResult>) returnValue; WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(deferredResult, mavContainer);
Modifier and Type | Method and Description |
---|---|
boolean |
isAsyncReturnValue(java.lang.Object returnValue,
MethodParameter returnType)
Whether the given return value represents asynchronous computation.
|
handleReturnValue, supportsReturnType
boolean isAsyncReturnValue(java.lang.Object returnValue, MethodParameter returnType)
returnValue
- the return valuereturnType
- the return typetrue
if the return value is asynchronous.