Interface AsyncHandlerMethodReturnValueHandler
- All Superinterfaces:
HandlerMethodReturnValueHandler
- All Known Implementing Classes:
AbstractAsyncReturnValueHandler,CompletableFutureReturnValueHandler,HandlerMethodReturnValueHandlerComposite,ListenableFutureReturnValueHandler,ReactiveReturnValueHandler
An extension of
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.
- Since:
- 4.2
- Author:
- Rossen Stoyanchev
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisAsyncReturnValue(Object returnValue, MethodParameter returnType) Whether the return value represents an asynchronous, Future-like type with success and error callbacks.toListenableFuture(Object returnValue, MethodParameter returnType) Adapt the asynchronous return value to aListenableFuture.Methods inherited from interface org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler
handleReturnValue, supportsReturnType
-
Method Details
-
isAsyncReturnValue
Whether the return value represents an asynchronous, Future-like type with success and error callbacks. If this method returnstrue, thentoListenableFuture(java.lang.Object, org.springframework.core.MethodParameter)is invoked next. If it returnsfalse, thenHandlerMethodReturnValueHandler.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 returnstrue.- Parameters:
returnValue- the value returned from the handler methodreturnType- the type of the return value- Returns:
trueif the return value type represents an async value
-
toListenableFuture
Adapt the asynchronous return value to aListenableFuture. Implementations should consider returning an instance ofSettableListenableFuture. 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 returnstrue.- Parameters:
returnValue- the value returned from the handler methodreturnType- the type of the return value- Returns:
- the resulting ListenableFuture, or
nullin which case no further handling will be performed
-