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

public Class CompletableFutureReturnValueHandler

extends AbstractAsyncReturnValueHandler
Class Inheritance
Imports
java.util.concurrent.CompletableFuture, .CompletionStage, org.springframework.core.MethodParameter

Support for CompletableFuture (and as of 4.3.7 also CompletionStage) as a return value type.
Authors
Sebastien Deleuze, Juergen Hoeller
Since
4.2

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
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 org.springframework.messaging.handler.invocation.AbstractAsyncReturnValueHandler:
handleReturnValueisAsyncReturnValue

Constructor Detail

CompletableFutureReturnValueHandlerback to summary
public CompletableFutureReturnValueHandler()

Method Detail

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