Top Description Fields Constructors Methods
org.springframework.web.reactive.result.method.annotation

public abstract Class AbstractMessageWriterResultHandler

extends HandlerResultHandlerSupport
Class Inheritance
Known Direct Subclasses
org.springframework.web.reactive.result.method.annotation.ResponseBodyResultHandler, org.springframework.web.reactive.result.method.annotation.ResponseEntityResultHandler
Imports
java.util.ArrayList, .Arrays, .List, .Set, org.reactivestreams.Publisher, reactor.core.publisher.Flux, .Mono, org.springframework.core.KotlinDetector, .MethodParameter, .ReactiveAdapter, .ReactiveAdapterRegistry, .ResolvableType, org.springframework.core.codec.Hints, org.springframework.http.HttpStatusCode, .MediaType, .ProblemDetail, org.springframework.http.codec.HttpMessageWriter, org.springframework.http.converter.HttpMessageNotWritableException, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .CollectionUtils, org.springframework.web.reactive.HandlerMapping, org.springframework.web.reactive.accept.RequestedContentTypeResolver, org.springframework.web.reactive.result.HandlerResultHandlerSupport, org.springframework.web.server.NotAcceptableStatusException, .ServerWebExchange

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

Field Summary

Modifier and TypeField and Description
protected static final String
private final List<HttpMessageWriter<?>>
private final List<MediaType>
Inherited from org.springframework.web.reactive.result.HandlerResultHandlerSupport:
logger

Constructor Summary

AccessConstructor and Description
protected
AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>>
for serializing Objects to the response body stream
messageWriters
,
RequestedContentTypeResolver
for resolving the requested content type
contentTypeResolver
)

Constructor with HttpMessageWriters and a RequestedContentTypeResolver.

protected
AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>>
for serializing Objects to the response body stream
messageWriters
,
RequestedContentTypeResolver
for resolving the requested content type
contentTypeResolver
,
ReactiveAdapterRegistry
for adapting other reactive types (e.g. rx.Observable, rx.Single, etc.) to Flux or Mono
adapterRegistry
)

Constructor with an additional ReactiveAdapterRegistry.

Method Summary

Modifier and TypeMethod and Description
private ResolvableType
private List<MediaType>
public List<HttpMessageWriter<?>>
getMessageWriters()

Return the configured message converters.

protected Mono<Void>

Returns:

indicates completion or error
writeBody
(Object
the object to write
body
,
MethodParameter
the MethodParameter of the body to write
bodyParameter
,
ServerWebExchange
the current exchange
exchange
)

Write a given body to the response with HttpMessageWriter.

protected Mono<Void>

Returns:

indicates completion or error
writeBody
(Object
the object to write
body
,
MethodParameter
the MethodParameter of the body to write
bodyParameter
,
MethodParameter
the actual return type of the method that returned the value; could be different from bodyParameter when processing HttpEntity for example
actualParam
,
ServerWebExchange
the current exchange
exchange
)

Write a given body to the response with HttpMessageWriter.

Inherited from org.springframework.web.reactive.result.HandlerResultHandlerSupport:
getAdaptergetAdapterRegistrygetContentTypeResolvergetOrderselectMediaTypeselectMediaTypesetOrder

Field Detail

COROUTINES_FLOW_CLASS_NAMEback to summary
protected static final String COROUTINES_FLOW_CLASS_NAME
messageWritersback to summary
private final List<HttpMessageWriter<?>> messageWriters
problemMediaTypesback to summary
private final List<MediaType> problemMediaTypes

Constructor Detail

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

Constructor with HttpMessageWriters and a RequestedContentTypeResolver.

Parameters
messageWriters:List<HttpMessageWriter<?>>

for serializing Objects to the response body stream

contentTypeResolver:RequestedContentTypeResolver

for resolving the requested content type

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

Constructor with an additional ReactiveAdapterRegistry.

Parameters
messageWriters:List<HttpMessageWriter<?>>

for serializing Objects to the response body stream

contentTypeResolver:RequestedContentTypeResolver

for resolving the requested content type

adapterRegistry:ReactiveAdapterRegistry

for adapting other reactive types (e.g. rx.Observable, rx.Single, etc.) to Flux or Mono

Method Detail

getElementTypeback to summary
private ResolvableType getElementType(ReactiveAdapter adapter, ResolvableType genericType)
getMediaTypesForback to summary
private List<MediaType> getMediaTypesFor(ResolvableType elementType)
getMessageWritersback to summary
public List<HttpMessageWriter<?>> getMessageWriters()

Return the configured message converters.

writeBodyback to summary
protected Mono<Void> writeBody(Object body, MethodParameter bodyParameter, ServerWebExchange exchange)

Write a given body to the response with HttpMessageWriter.

Parameters
body:Object

the object to write

bodyParameter:MethodParameter

the MethodParameter of the body to write

exchange:ServerWebExchange

the current exchange

Returns:Mono<Void>

indicates completion or error

See Also
writeBody(Object, MethodParameter, MethodParameter, ServerWebExchange)
writeBodyback to summary
protected Mono<Void> writeBody(Object body, MethodParameter bodyParameter, MethodParameter actualParam, ServerWebExchange exchange)

Write a given body to the response with HttpMessageWriter.

Parameters
body:Object

the object to write

bodyParameter:MethodParameter

the MethodParameter of the body to write

actualParam:MethodParameter

the actual return type of the method that returned the value; could be different from bodyParameter when processing HttpEntity for example

exchange:ServerWebExchange

the current exchange

Returns:Mono<Void>

indicates completion or error

Annotations
@SuppressWarnings:rawtypes, unchecked, ConstantConditions
Since
5.0.2