Class AbstractAsyncReturnValueHandler
java.lang.Object
org.springframework.messaging.handler.invocation.AbstractAsyncReturnValueHandler
- All Implemented Interfaces:
AsyncHandlerMethodReturnValueHandler
,HandlerMethodReturnValueHandler
- Direct Known Subclasses:
CompletableFutureReturnValueHandler
,ListenableFutureReturnValueHandler
,ReactiveReturnValueHandler
public abstract class AbstractAsyncReturnValueHandler
extends Object
implements AsyncHandlerMethodReturnValueHandler
Convenient base class for
AsyncHandlerMethodReturnValueHandler
implementations that support only asynchronous (Future-like) return values
and merely serve as adapters of such types to Spring's
ListenableFuture
.- Since:
- 4.2
- Author:
- Sebastien Deleuze
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
handleReturnValue
(Object returnValue, MethodParameter returnType, Message<?> message) Handle the given return value.boolean
isAsyncReturnValue
(Object returnValue, MethodParameter returnType) Whether the return value represents an asynchronous, Future-like type with success and error callbacks.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.messaging.handler.invocation.AsyncHandlerMethodReturnValueHandler
toCompletableFuture, toListenableFuture
Methods inherited from interface org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler
supportsReturnType
-
Constructor Details
-
AbstractAsyncReturnValueHandler
public AbstractAsyncReturnValueHandler()
-
-
Method Details
-
isAsyncReturnValue
Description copied from interface:AsyncHandlerMethodReturnValueHandler
Whether the return value represents an asynchronous, Future-like type with success and error callbacks. If this method returnstrue
, thenAsyncHandlerMethodReturnValueHandler.toCompletableFuture(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
.- Specified by:
isAsyncReturnValue
in interfaceAsyncHandlerMethodReturnValueHandler
- Parameters:
returnValue
- the value returned from the handler methodreturnType
- the type of the return value- Returns:
true
if the return value type represents an async value
-
handleReturnValue
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, Message<?> message) Description copied from interface:HandlerMethodReturnValueHandler
Handle the given return value.- Specified by:
handleReturnValue
in interfaceHandlerMethodReturnValueHandler
- Parameters:
returnValue
- the value returned from the handler methodreturnType
- the type of the return value. This type must have previously been passed toHandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)
and it must have returnedtrue
.message
- the message that caused this method to be called
-