org.springframework.messaging.handler.invocation

## Class ReactiveReturnValueHandler

- java.lang.Object
- - org.springframework.messaging.handler.invocation.AbstractAsyncReturnValueHandler
  - - org.springframework.messaging.handler.invocation.ReactiveReturnValueHandler

- All Implemented Interfaces:
    AsyncHandlerMethodReturnValueHandler, HandlerMethodReturnValueHandler

      public class ReactiveReturnValueHandler
      extends AbstractAsyncReturnValueHandler

  Support for single-value reactive types (like `Mono` or `Single`) as a return value type.
  Since:
    5.1
  Author:
    Sebastien Deleuze

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReactiveReturnValueHandler()`
    `ReactiveReturnValueHandler(ReactiveAdapterRegistry adapterRegistry)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isAsyncReturnValue(Object returnValue, MethodParameter returnType)` Whether the return value represents an asynchronous, Future-like type with success and error callbacks.
    `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 a `ListenableFuture`.

    - ### Methods inherited from class org.springframework.messaging.handler.invocation.AbstractAsyncReturnValueHandler

      `handleReturnValue`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ReactiveReturnValueHandler

          public ReactiveReturnValueHandler()

    - #### ReactiveReturnValueHandler

          public ReactiveReturnValueHandler(ReactiveAdapterRegistry adapterRegistry)

  - ### Method Detail

    - #### supportsReturnType

          public boolean supportsReturnType(MethodParameter returnType)

      Description copied from interface: `HandlerMethodReturnValueHandler`
      Whether the given method return type is supported by this handler.
      Parameters:
        `returnType` - the method return type to check
      Returns:
        `true` if this handler supports the supplied return type; `false` otherwise

    - #### isAsyncReturnValue

          public boolean isAsyncReturnValue(Object returnValue,
                                            MethodParameter returnType)

      Description copied from interface: `AsyncHandlerMethodReturnValueHandler`
      Whether the return value represents an asynchronous, Future-like type with success and error callbacks. If this method returns `true`, then `AsyncHandlerMethodReturnValueHandler.toListenableFuture(java.lang.Object, org.springframework.core.MethodParameter)` is invoked next. If it returns `false`, then `HandlerMethodReturnValueHandler.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 returns `true`.

      Specified by:
        `isAsyncReturnValue` in interface `AsyncHandlerMethodReturnValueHandler`
      Overrides:
        `isAsyncReturnValue` in class `AbstractAsyncReturnValueHandler`
      Parameters:
        `returnValue` - the value returned from the handler method
        `returnType` - the type of the return value
      Returns:
        `true` if the return value type represents an async value

    - #### toListenableFuture

          public ListenableFuture<?> toListenableFuture(Object returnValue,
                                                        MethodParameter returnType)

      Description copied from interface: `AsyncHandlerMethodReturnValueHandler`
      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 `HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)` is called and it returns `true`.

      Parameters:
        `returnValue` - the value returned from the handler method
        `returnType` - the type of the return value
      Returns:
        the resulting ListenableFuture, or `null` in which case no further handling will be performed