Interface AsyncHandlerMethodReturnValueHandler
- All Superinterfaces:
HandlerMethodReturnValueHandler
- All Known Implementing Classes:
AbstractAsyncReturnValueHandler,CompletableFutureReturnValueHandler,HandlerMethodReturnValueHandlerComposite,ReactiveReturnValueHandler
An extension of
HandlerMethodReturnValueHandler for handling async,
Future-like return value types that support success and error callbacks.
Implementations should consider extending the convenient base class
AbstractAsyncReturnValueHandler.
- Since:
- 4.2
- Author:
- Rossen Stoyanchev
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisAsyncReturnValue(Object returnValue, org.springframework.core.MethodParameter returnType) Whether the return value represents an asynchronous, Future-like type with success and error callbacks.toCompletableFuture(Object returnValue, org.springframework.core.MethodParameter returnType) Adapt the asynchronous return value to aCompletableFuture.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, thentoCompletableFuture(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
-
toCompletableFuture
@Nullable CompletableFuture<?> toCompletableFuture(Object returnValue, org.springframework.core.MethodParameter returnType) Adapt the asynchronous return value to aCompletableFuture.Return value handling will then continue when the CompletableFuture 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 CompletableFuture, or
nullin which case no further handling will be performed - Since:
- 6.0
-