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

public Interface AsyncHandlerMethodReturnValueHandler

extends HandlerMethodReturnValueHandler
Known Direct Implementers
org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandlerComposite, org.springframework.messaging.handler.invocation.AbstractAsyncReturnValueHandler
Imports
java.util.concurrent.CompletableFuture, org.springframework.core.MethodParameter, org.springframework.lang.Nullable

An extension of HandlerMethodReturnValueHandler for handling async, Future-like return value types that support success and error callbacks. Essentially anything that can be adapted to a ListenableFuture.

Implementations should consider extending the convenient base class AbstractAsyncReturnValueHandler.

Author
Rossen Stoyanchev
Since
4.2
See Also
AbstractAsyncReturnValueHandler

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the return value type represents an async value
isAsyncReturnValue
(Object
the value returned from the handler method
returnValue
,
MethodParameter
the type of the return value
returnType
)

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

public CompletableFuture<?>

Returns:

the resulting CompletableFuture, or null in which case no further handling will be performed
toCompletableFuture
(Object
the value returned from the handler method
returnValue
,
MethodParameter
the type of the return value
returnType
)

Adapt the asynchronous return value to a CompletableFuture.

public default ListenableFuture<?>

Returns:

the resulting ListenableFuture, or null in which case no further handling will be performed
toListenableFuture
(Object
the value returned from the handler method
returnValue
,
MethodParameter
the type of the return value
returnType
)
Deprecated since 6.0. as of 6.0, in favor of toCompletableFuture(Object, MethodParameter)

Adapt the asynchronous return value to a ListenableFuture.

Inherited from org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler:
handleReturnValuesupportsReturnType

Method Detail

isAsyncReturnValueback to summary
public boolean isAsyncReturnValue(Object returnValue, MethodParameter returnType)

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

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

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
@Nullable
Since
6.0
toListenableFutureback to summary
public default ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType)

Deprecated

since 6.0.

as of 6.0, in favor of toCompletableFuture(Object, MethodParameter)

Adapt the asynchronous return value to a ListenableFuture.

Implementations should consider returning an instance of SettableListenableFuture. Return value handling will then continue when the ListenableFuture 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:ListenableFuture<?>

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

Annotations
@Deprecated
since:6.0
@Nullable