Class ReactiveReturnValueHandler
java.lang.Object
org.springframework.messaging.handler.invocation.AbstractAsyncReturnValueHandler
org.springframework.messaging.handler.invocation.ReactiveReturnValueHandler
- All Implemented Interfaces:
AsyncHandlerMethodReturnValueHandler, HandlerMethodReturnValueHandler
Support for single-value reactive types (like
Mono or Single)
as a return value type.- Since:
- 5.1
- Author:
- Sebastien Deleuze
-
Constructor Summary
ConstructorsConstructorDescriptionReactiveReturnValueHandler(org.springframework.core.ReactiveAdapterRegistry adapterRegistry) -
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.booleansupportsReturnType(org.springframework.core.MethodParameter returnType) Whether the given method return type is supported by this handler.toCompletableFuture(Object returnValue, org.springframework.core.MethodParameter returnType) Adapt the asynchronous return value to aCompletableFuture.Methods inherited from class AbstractAsyncReturnValueHandler
handleReturnValue
-
Constructor Details
-
ReactiveReturnValueHandler
public ReactiveReturnValueHandler() -
ReactiveReturnValueHandler
public ReactiveReturnValueHandler(org.springframework.core.ReactiveAdapterRegistry adapterRegistry)
-
-
Method Details
-
supportsReturnType
public boolean supportsReturnType(org.springframework.core.MethodParameter returnType) Description copied from interface:HandlerMethodReturnValueHandlerWhether the given method return type is supported by this handler.- Parameters:
returnType- the method return type to check- Returns:
trueif this handler supports the supplied return type;falseotherwise
-
isAsyncReturnValue
public boolean isAsyncReturnValue(Object returnValue, org.springframework.core.MethodParameter returnType) Description copied from interface:AsyncHandlerMethodReturnValueHandlerWhether the return value represents an asynchronous, Future-like type with success and error callbacks. If this method returnstrue, thenAsyncHandlerMethodReturnValueHandler.toCompletableFuture(Object, MethodParameter)is invoked next. If it returnsfalse, thenHandlerMethodReturnValueHandler.handleReturnValue(Object, MethodParameter, Message)is called.Note: this method will only be invoked after
HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)is called and it returnstrue.- Specified by:
isAsyncReturnValuein interfaceAsyncHandlerMethodReturnValueHandler- Overrides:
isAsyncReturnValuein classAbstractAsyncReturnValueHandler- 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
public @Nullable CompletableFuture<?> toCompletableFuture(Object returnValue, org.springframework.core.MethodParameter returnType) Description copied from interface:AsyncHandlerMethodReturnValueHandlerAdapt 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
-