public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodReturnValueHandler
HandlerMethodReturnValueHandler
for handling async,
Future-like return value types that support success and error callbacks.
Essentially anything that can be adapted to a ListenableFuture
.
Implementations should consider extending the convenient base class
AbstractAsyncReturnValueHandler
.
AbstractAsyncReturnValueHandler
Modifier and Type | Method and Description |
---|---|
boolean |
isAsyncReturnValue(java.lang.Object returnValue,
MethodParameter returnType)
Whether the return value represents an asynchronous, Future-like type
with success and error callbacks.
|
ListenableFuture<?> |
toListenableFuture(java.lang.Object returnValue,
MethodParameter returnType)
Adapt the asynchronous return value to a
ListenableFuture . |
handleReturnValue, supportsReturnType
boolean isAsyncReturnValue(java.lang.Object returnValue, MethodParameter returnType)
true
,
then toListenableFuture(java.lang.Object, org.springframework.core.MethodParameter)
is invoked next. If it returns
false
, then HandlerMethodReturnValueHandler.handleReturnValue(java.lang.Object, org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>)
is called.
Note: this method will only be invoked after
HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)
is called and it returns true
.
returnValue
- the value returned from the handler methodreturnType
- the type of the return value.ListenableFuture<?> toListenableFuture(java.lang.Object returnValue, MethodParameter returnType)
ListenableFuture
.
Implementations should consider returning an instance of
SettableListenableFuture
. Return value handling will then continue when
the ListenableFuture is completed with either success or error.
Note: this method will only be invoked after
HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)
is called and it returns true
.
returnValue
- the value returned from the handler methodreturnType
- the type of the return value.null
in which case no
further handling will be performed.