类 HandlerMethodReturnValueHandlerComposite
- java.lang.Object
- org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandlerComposite
public class HandlerMethodReturnValueHandlerComposite extends Object implements AsyncHandlerMethodReturnValueHandler
A HandlerMethodReturnValueHandler that wraps and delegates to others.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
字段概要
字段 修饰符和类型 字段 说明 static Log
defaultLogger
Public for wrapping with fallback logger.
构造器概要
构造器 构造器 说明 HandlerMethodReturnValueHandlerComposite()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 HandlerMethodReturnValueHandlerComposite
addHandler(HandlerMethodReturnValueHandler returnValueHandler)
Add the givenHandlerMethodReturnValueHandler
.HandlerMethodReturnValueHandlerComposite
addHandlers(List<? extends HandlerMethodReturnValueHandler> handlers)
Add the givenHandlerMethodReturnValueHandlers
.void
clear()
Clear the list of configured handlers.Log
getLogger()
Return the currently configured Logger.List<HandlerMethodReturnValueHandler>
getReturnValueHandlers()
Return a read-only list with the configured handlers.void
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.void
setLogger(Log logger)
Set an alternative logger to use than the one based on the class name.boolean
supportsReturnType(MethodParameter returnType)
Whether the given method return type is supported by this handler.ListenableFuture<?>
toListenableFuture(Object returnValue, MethodParameter returnType)
Adapt the asynchronous return value to aListenableFuture
.
字段详细资料
defaultLogger
public static final Log defaultLogger
Public for wrapping with fallback logger.
构造器详细资料
HandlerMethodReturnValueHandlerComposite
public HandlerMethodReturnValueHandlerComposite()
方法详细资料
setLogger
public void setLogger(Log logger)
Set an alternative logger to use than the one based on the class name.- 参数:
logger
- the logger to use- 从以下版本开始:
- 5.1
getReturnValueHandlers
public List<HandlerMethodReturnValueHandler> getReturnValueHandlers()
Return a read-only list with the configured handlers.
clear
public void clear()
Clear the list of configured handlers.
addHandler
public HandlerMethodReturnValueHandlerComposite addHandler(HandlerMethodReturnValueHandler returnValueHandler)
Add the givenHandlerMethodReturnValueHandler
.
addHandlers
public HandlerMethodReturnValueHandlerComposite addHandlers(@Nullable List<? extends HandlerMethodReturnValueHandler> handlers)
Add the givenHandlerMethodReturnValueHandlers
.
supportsReturnType
public boolean supportsReturnType(MethodParameter returnType)
从接口复制的说明:HandlerMethodReturnValueHandler
Whether the given method return type is supported by this handler.- 指定者:
supportsReturnType
在接口中HandlerMethodReturnValueHandler
- 参数:
returnType
- the method return type to check- 返回:
true
if this handler supports the supplied return type;false
otherwise
handleReturnValue
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, Message<?> message) throws Exception
从接口复制的说明:HandlerMethodReturnValueHandler
Handle the given return value.- 指定者:
handleReturnValue
在接口中HandlerMethodReturnValueHandler
- 参数:
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- 抛出:
Exception
- if the return value handling results in an error
isAsyncReturnValue
public boolean isAsyncReturnValue(Object returnValue, MethodParameter returnType)
从接口复制的说明:AsyncHandlerMethodReturnValueHandler
Whether the return value represents an asynchronous, Future-like type with success and error callbacks. If this method returnstrue
, thenAsyncHandlerMethodReturnValueHandler.toListenableFuture(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
.- 指定者:
isAsyncReturnValue
在接口中AsyncHandlerMethodReturnValueHandler
- 参数:
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
@Nullable public ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType)
从接口复制的说明:AsyncHandlerMethodReturnValueHandler
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
.- 指定者:
toListenableFuture
在接口中AsyncHandlerMethodReturnValueHandler
- 参数:
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