Top Description Fields Constructors Methods
org.springframework.messaging.handler.invocation

public Class HandlerMethodReturnValueHandlerComposite

extends Object
implements AsyncHandlerMethodReturnValueHandler
Class Inheritance
All Implemented Interfaces
org.springframework.messaging.handler.invocation.AsyncHandlerMethodReturnValueHandler, org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler
Imports
java.util.ArrayList, .Collections, .List, java.util.concurrent.CompletableFuture, org.apache.commons.logging.Log, .LogFactory, org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.messaging.Message

A HandlerMethodReturnValueHandler that wraps and delegates to others.
Author
Rossen Stoyanchev
Since
4.0

Field Summary

Modifier and TypeField and Description
public static final Log
defaultLogger

Public for wrapping with fallback logger.

private Log
private final List<HandlerMethodReturnValueHandler>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public HandlerMethodReturnValueHandlerComposite
public HandlerMethodReturnValueHandlerComposite
public void
clear()

Clear the list of configured handlers.

public Log
getLogger()

Return the currently configured Logger.

private HandlerMethodReturnValueHandler
public List<HandlerMethodReturnValueHandler>
getReturnValueHandlers()

Return a read-only list with the configured handlers.

public void
handleReturnValue(Object
the value returned from the handler method
returnValue
,
MethodParameter
the type of the return value. This type must have previously been passed to supportsReturnType(org.springframework.core.MethodParameter) and it must have returned true.
returnType
,
Message<?>
the message that caused this method to be called
message
)

Implements org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler.handleReturnValue.

Handle the given return value.

public boolean
isAsyncReturnValue(Object
the value returned from the handler method
returnValue
,
MethodParameter
the type of the return value
returnType
)

Implements org.springframework.messaging.handler.invocation.AsyncHandlerMethodReturnValueHandler.isAsyncReturnValue.

Whether the return value represents an asynchronous, Future-like type with success and error callbacks.

public void
setLogger(Log
the logger to use
logger
)

Set an alternative logger to use than the one based on the class name.

public boolean
supportsReturnType(MethodParameter
the method return type to check
returnType
)

Implements org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler.supportsReturnType.

Whether the given method return type is supported by this handler.

public CompletableFuture<?>
toCompletableFuture(Object
the value returned from the handler method
returnValue
,
MethodParameter
the type of the return value
returnType
)

Implements org.springframework.messaging.handler.invocation.AsyncHandlerMethodReturnValueHandler.toCompletableFuture.

Adapt the asynchronous return value to a CompletableFuture.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultLoggerback to summary
public static final Log defaultLogger

Public for wrapping with fallback logger.

loggerback to summary
private Log logger
returnValueHandlersback to summary
private final List<HandlerMethodReturnValueHandler> returnValueHandlers

Constructor Detail

HandlerMethodReturnValueHandlerCompositeback to summary
public HandlerMethodReturnValueHandlerComposite()

Method Detail

addHandlerback to summary
public HandlerMethodReturnValueHandlerComposite addHandler(HandlerMethodReturnValueHandler returnValueHandler)

Add the given HandlerMethodReturnValueHandler.

addHandlersback to summary
public HandlerMethodReturnValueHandlerComposite addHandlers(List<? extends HandlerMethodReturnValueHandler> handlers)

Add the given HandlerMethodReturnValueHandlers.

clearback to summary
public void clear()

Clear the list of configured handlers.

getLoggerback to summary
public Log getLogger()

Return the currently configured Logger.

Since
5.1
getReturnValueHandlerback to summary
private HandlerMethodReturnValueHandler getReturnValueHandler(MethodParameter returnType)
Annotations
@SuppressWarnings:ForLoopReplaceableByForEach
@Nullable
getReturnValueHandlersback to summary
public List<HandlerMethodReturnValueHandler> getReturnValueHandlers()

Return a read-only list with the configured handlers.

handleReturnValueback to summary
public void handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message) throws Exception

Implements org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler.handleReturnValue.

Doc from org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler.handleReturnValue.

Handle the given return value.

Parameters
returnValue:Object

the value returned from the handler method

returnType:MethodParameter

the type of the return value. This type must have previously been passed to supportsReturnType(org.springframework.core.MethodParameter) and it must have returned true.

message:Message<?>

the message that caused this method to be called

Annotations
@Override
Exceptions
Exception:
if the return value handling results in an error
isAsyncReturnValueback to summary
public boolean isAsyncReturnValue(Object returnValue, MethodParameter returnType)

Implements org.springframework.messaging.handler.invocation.AsyncHandlerMethodReturnValueHandler.isAsyncReturnValue.

Doc from org.springframework.messaging.handler.invocation.AsyncHandlerMethodReturnValueHandler.isAsyncReturnValue.

Whether the return value represents an asynchronous, Future-like type with success and error callbacks. If this method returns true, then toCompletableFuture is invoked next. If it returns false, then handleReturnValue is called.

Note

this method will only be invoked after supportsReturnType(org.springframework.core.MethodParameter) is called and it returns true.

Parameters
returnValue:Object

the value returned from the handler method

returnType:MethodParameter

the type of the return value

Returns:boolean

true if the return value type represents an async value

Annotations
@Override
setLoggerback to summary
public void setLogger(Log logger)

Set an alternative logger to use than the one based on the class name.

Parameters
logger:Log

the logger to use

Since
5.1
supportsReturnTypeback to summary
public boolean supportsReturnType(MethodParameter returnType)

Implements org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler.supportsReturnType.

Doc from org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler.supportsReturnType.

Whether the given method return type is supported by this handler.

Parameters
returnType:MethodParameter

the method return type to check

Returns:boolean

true if this handler supports the supplied return type; false otherwise

Annotations
@Override
toCompletableFutureback to summary
public CompletableFuture<?> toCompletableFuture(Object returnValue, MethodParameter returnType)

Implements org.springframework.messaging.handler.invocation.AsyncHandlerMethodReturnValueHandler.toCompletableFuture.

Doc from org.springframework.messaging.handler.invocation.AsyncHandlerMethodReturnValueHandler.toCompletableFuture.

Adapt the asynchronous return value to a CompletableFuture.

Return value handling will then continue when the CompletableFuture is completed with either success or error.

Note

this method will only be invoked after supportsReturnType(org.springframework.core.MethodParameter) is called and it returns true.

Parameters
returnValue:Object

the value returned from the handler method

returnType:MethodParameter

the type of the return value

Returns:CompletableFuture<?>

the resulting CompletableFuture, or null in which case no further handling will be performed

Annotations
@Override
@Nullable