org.springframework.web.reactive.result.method.annotation

## Class AbstractMessageWriterResultHandler

- java.lang.Object
- - org.springframework.web.reactive.result.HandlerResultHandlerSupport
  - - org.springframework.web.reactive.result.method.annotation.AbstractMessageWriterResultHandler

- All Implemented Interfaces:
    Ordered
  Direct Known Subclasses:
    ResponseBodyResultHandler, ResponseEntityResultHandler

      public abstract class AbstractMessageWriterResultHandler
      extends HandlerResultHandlerSupport

  Abstract base class for result handlers that handle return values by writing to the response with `HttpMessageWriter`.
  Since:
    5.0
  Author:
    Rossen Stoyanchev, Sebastien Deleuze

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `COROUTINES_FLOW_CLASS_NAME`

    - ### Fields inherited from class org.springframework.web.reactive.result.HandlerResultHandlerSupport

      `logger`

    - ### Fields inherited from interface org.springframework.core.Ordered

      `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>> messageWriters, RequestedContentTypeResolver contentTypeResolver)` Constructor with `HttpMessageWriters` and a `RequestedContentTypeResolver`.
    `protected` | `AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>> messageWriters, RequestedContentTypeResolver contentTypeResolver, ReactiveAdapterRegistry adapterRegistry)` Constructor with an additional `ReactiveAdapterRegistry`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<HttpMessageWriter<?>>` | `getMessageWriters()` Return the configured message converters.
    `protected reactor.core.publisher.Mono<Void>` | `writeBody(Object body, MethodParameter bodyParameter, MethodParameter actualParam, ServerWebExchange exchange)` Write a given body to the response with `HttpMessageWriter`.
    `protected reactor.core.publisher.Mono<Void>` | `writeBody(Object body, MethodParameter bodyParameter, ServerWebExchange exchange)` Write a given body to the response with `HttpMessageWriter`.

    - ### Methods inherited from class org.springframework.web.reactive.result.HandlerResultHandlerSupport

      `getAdapter, getAdapterRegistry, getContentTypeResolver, getOrder, selectMediaType, setOrder`

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

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

- - ### Field Detail

    - #### COROUTINES_FLOW_CLASS_NAME

          protected static final String COROUTINES_FLOW_CLASS_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AbstractMessageWriterResultHandler

          protected AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>> messageWriters,
                                                       RequestedContentTypeResolver contentTypeResolver)

      Constructor with `HttpMessageWriters` and a `RequestedContentTypeResolver`.
      Parameters:
        `messageWriters` - for serializing Objects to the response body stream
        `contentTypeResolver` - for resolving the requested content type

    - #### AbstractMessageWriterResultHandler

          protected AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>> messageWriters,
                                                       RequestedContentTypeResolver contentTypeResolver,
                                                       ReactiveAdapterRegistry adapterRegistry)

      Constructor with an additional `ReactiveAdapterRegistry`.
      Parameters:
        `messageWriters` - for serializing Objects to the response body stream
        `contentTypeResolver` - for resolving the requested content type
        `adapterRegistry` - for adapting other reactive types (e.g. rx.Observable, rx.Single, etc.) to Flux or Mono

  - ### Method Detail

    - #### getMessageWriters

          public List<HttpMessageWriter<?>> getMessageWriters()

      Return the configured message converters.

    - #### writeBody

          protected reactor.core.publisher.Mono<Void> writeBody(@Nullable
                                                                Object body,
                                                                MethodParameter bodyParameter,
                                                                ServerWebExchange exchange)

      Write a given body to the response with `HttpMessageWriter`.
      Parameters:
        `body` - the object to write
        `bodyParameter` - the `MethodParameter` of the body to write
        `exchange` - the current exchange
      Returns:
        indicates completion or error
      See Also:
        `writeBody(Object, MethodParameter, MethodParameter, ServerWebExchange)`

    - #### writeBody

          protected reactor.core.publisher.Mono<Void> writeBody(@Nullable
                                                                Object body,
                                                                MethodParameter bodyParameter,
                                                                @Nullable
                                                                MethodParameter actualParam,
                                                                ServerWebExchange exchange)

      Write a given body to the response with `HttpMessageWriter`.
      Parameters:
        `body` - the object to write
        `bodyParameter` - the `MethodParameter` of the body to write
        `actualParam` - the actual return type of the method that returned the value; could be different from `bodyParameter` when processing `HttpEntity` for example
        `exchange` - the current exchange
      Returns:
        indicates completion or error
      Since:
        5.0.2