接口 AsyncHandlerMethodReturnValueHandler
- 所有已知实现类:
AbstractAsyncReturnValueHandler
,CompletableFutureReturnValueHandler
,HandlerMethodReturnValueHandlerComposite
,ListenableFutureReturnValueHandler
public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodReturnValueHandler
An extension ofHandlerMethodReturnValueHandler
for handling async, Future-like return value types that support success and error callbacks. Essentially anything that can be adapted to aListenableFuture
.Implementations should consider extending the convenient base class
AbstractAsyncReturnValueHandler
.- 从以下版本开始:
- 4.2
- 作者:
- Rossen Stoyanchev
- 另请参阅:
AbstractAsyncReturnValueHandler
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 boolean
isAsyncReturnValue(Object returnValue, MethodParameter returnType)
Whether the return value represents an asynchronous, Future-like type with success and error callbacks.ListenableFuture<?>
toListenableFuture(Object returnValue, MethodParameter returnType)
Adapt the asynchronous return value to aListenableFuture
.从接口继承的方法 org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler
handleReturnValue, supportsReturnType
方法详细资料
isAsyncReturnValue
boolean isAsyncReturnValue(Object returnValue, MethodParameter returnType)
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
.- 参数:
returnValue
- the value returned from the handler methodreturnType
- the type of the return value- 返回:
true
if the return value type represents an async value
toListenableFuture
ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType)
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
.- 参数:
returnValue
- the value returned from the handler methodreturnType
- the type of the return value- 返回:
- the resulting ListenableFuture, or
null
in which case no further handling will be performed