org.springframework.messaging.handler.invocation.reactive

## Class AbstractEncoderMethodReturnValueHandler

- java.lang.Object
- - org.springframework.messaging.handler.invocation.reactive.AbstractEncoderMethodReturnValueHandler

- All Implemented Interfaces:
    HandlerMethodReturnValueHandler
  Direct Known Subclasses:
    RSocketPayloadReturnValueHandler

      public abstract class AbstractEncoderMethodReturnValueHandler
      extends Object
      implements HandlerMethodReturnValueHandler

  Base class for a return value handler that encodes return values to `Flux<DataBuffer>` through the configured `Encoder`s.

  Subclasses must implement the abstract method `handleEncodedContent(reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer>, org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>)` to handle the resulting encoded content.

  This handler should be ordered last since its `supportsReturnType(org.springframework.core.MethodParameter)` returns `true` for any method parameter type.

  Since:
    5.2
  Author:
    Rossen Stoyanchev

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Log` | `logger`

    - ### Fields inherited from interface org.springframework.messaging.handler.invocation.reactive.HandlerMethodReturnValueHandler

      `DATA_BUFFER_FACTORY_HEADER`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractEncoderMethodReturnValueHandler(List<Encoder<?>> encoders, ReactiveAdapterRegistry registry)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ReactiveAdapterRegistry` | `getAdapterRegistry()` The configured adapter registry.
    `List<Encoder<?>>` | `getEncoders()` The configured encoders.
    `protected abstract reactor.core.publisher.Mono<Void>` | `handleEncodedContent(reactor.core.publisher.Flux<DataBuffer> encodedContent, MethodParameter returnType, Message<?> message)` Subclasses implement this method to handle encoded values in some way such as creating and sending messages.
    `protected abstract reactor.core.publisher.Mono<Void>` | `handleNoContent(MethodParameter returnType, Message<?> message)` Invoked for a `null` return value, which could mean a void method or method returning an async type parameterized by void.
    `reactor.core.publisher.Mono<Void>` | `handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message)` Handle the given return value.
    `boolean` | `supportsReturnType(MethodParameter returnType)` Whether the given method return type is supported by this handler.

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

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

- - ### Field Detail

    - #### logger

          protected final Log logger

  - ### Constructor Detail

    - #### AbstractEncoderMethodReturnValueHandler

          protected AbstractEncoderMethodReturnValueHandler(List<Encoder<?>> encoders,
                                                            ReactiveAdapterRegistry registry)

  - ### Method Detail

    - #### getEncoders

          public List<Encoder<?>> getEncoders()

      The configured encoders.

    - #### getAdapterRegistry

          public ReactiveAdapterRegistry getAdapterRegistry()

      The configured adapter registry.

    - #### supportsReturnType

          public boolean supportsReturnType(MethodParameter returnType)

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

    - #### handleReturnValue

          public reactor.core.publisher.Mono<Void> handleReturnValue(@Nullable
                                                                     Object returnValue,
                                                                     MethodParameter returnType,
                                                                     Message<?> message)

      Description copied from interface: `HandlerMethodReturnValueHandler`
      Handle the given return value.
      Specified by:
        `handleReturnValue` in interface `HandlerMethodReturnValueHandler`
      Parameters:
        `returnValue` - the value returned from the handler method
        `returnType` - the type of the return value. This type must have previously been passed to `HandlerMethodReturnValueHandler.supportsReturnType(MethodParameter)` and it must have returned `true`.
      Returns:
        `Mono<Void>` to indicate when handling is complete.

    - #### handleEncodedContent

          protected abstract reactor.core.publisher.Mono<Void> handleEncodedContent(reactor.core.publisher.Flux<DataBuffer> encodedContent,
                                                                                    MethodParameter returnType,
                                                                                    Message<?> message)

      Subclasses implement this method to handle encoded values in some way such as creating and sending messages.
      Parameters:
        `encodedContent` - the encoded content; each `DataBuffer` represents the fully-aggregated, encoded content for one value (i.e. payload) returned from the HandlerMethod.
        `returnType` - return type of the handler method that produced the data
        `message` - the input message handled by the handler method
      Returns:
        completion `Mono<Void>` for the handling

    - #### handleNoContent

          protected abstract reactor.core.publisher.Mono<Void> handleNoContent(MethodParameter returnType,
                                                                               Message<?> message)

      Invoked for a `null` return value, which could mean a void method or method returning an async type parameterized by void.
      Parameters:
        `returnType` - return type of the handler method that produced the data
        `message` - the input message handled by the handler method
      Returns:
        completion `Mono<Void>` for the handling