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

public abstract Class AbstractMessageReaderArgumentResolver

extends HandlerMethodArgumentResolverSupport
Class Inheritance
Known Direct Subclasses
org.springframework.web.reactive.result.method.annotation.HttpEntityMethodArgumentResolver, org.springframework.web.reactive.result.method.annotation.RequestBodyMethodArgumentResolver, org.springframework.web.reactive.result.method.annotation.RequestPartMethodArgumentResolver
Imports
java.lang.annotation.Annotation, java.util.ArrayList, .List, .Map, .Set, reactor.core.publisher.Flux, .Mono, org.springframework.context.i18n.LocaleContextHolder, org.springframework.core.Conventions, .MethodParameter, .ReactiveAdapter, .ReactiveAdapterRegistry, .ResolvableType, org.springframework.core.codec.DecodingException, .Hints, org.springframework.core.io.buffer.DataBuffer, .DataBufferUtils, org.springframework.http.HttpHeaders, .HttpMethod, .HttpStatus, .InvalidMediaTypeException, .MediaType, org.springframework.http.codec.HttpMessageReader, org.springframework.http.server.reactive.ServerHttpRequest, .ServerHttpResponse, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.validation.Validator, org.springframework.validation.annotation.ValidationAnnotationUtils, org.springframework.web.bind.support.WebExchangeBindException, .WebExchangeDataBinder, org.springframework.web.reactive.BindingContext, org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport, org.springframework.web.server.ResponseStatusException, .ServerWebExchange, .ServerWebInputException, .UnsupportedMediaTypeStatusException

Abstract base class for argument resolvers that resolve method arguments by reading the request body with an HttpMessageReader.

Applies validation if the method argument is annotated with any annotations that trigger validation. Validation failure results in a ServerWebInputException.

Authors
Rossen Stoyanchev, Sebastien Deleuze
Since
5.0

Field Summary

Modifier and TypeField and Description
private final List<HttpMessageReader<?>>
private static final Set<HttpMethod>
Inherited from org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport:
logger

Constructor Summary

AccessConstructor and Description
protected
AbstractMessageReaderArgumentResolver(List<HttpMessageReader<?>>
the readers to convert from the request body
readers
)

Constructor with HttpMessageReader's and a Validator.

protected
AbstractMessageReaderArgumentResolver(List<HttpMessageReader<?>>
readers to convert from the request body
messageReaders
,
ReactiveAdapterRegistry
for adapting to other reactive types from Flux and Mono
adapterRegistry
)

Constructor that also accepts a ReactiveAdapterRegistry.

Method Summary

Modifier and TypeMethod and Description
private Object[]
extractValidationHints(MethodParameter parameter)

Check if the given MethodParameter requires validation and if so return a (possibly empty) Object[] with validation hints.

public List<HttpMessageReader<?>>
getMessageReaders()

Return the configured message converters.

private List<MediaType>
private ServerWebInputException
private Throwable
protected Mono<Object>

Returns:

the body
readBody
(MethodParameter
the MethodParameter to read
bodyParameter
,
boolean
true if the body is required
isBodyRequired
,
BindingContext
the binding context to use
bindingContext
,
ServerWebExchange
the current exchange
exchange
)

Read the body from a method argument with HttpMessageReader.

protected Mono<Object>

Returns:

a Mono with the value to use for the method argument
readBody
(MethodParameter
represents the element type for the body
bodyParam
,
MethodParameter
the actual method argument type; possibly different from bodyParam, e.g. for an HttpEntity argument
actualParam
,
boolean
true if the body is required
isBodyRequired
,
BindingContext
the binding context to use
bindingContext
,
ServerWebExchange
the current exchange
exchange
)

Read the body from a method argument with HttpMessageReader.

private void
validate(Object target, Object[] validationHints, MethodParameter parameter, BindingContext binding, ServerWebExchange exchange)

Inherited from org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport:
checkAnnotatedParamNoReactiveWrappercheckParameterTypecheckParameterTypeNoReactiveWrappergetAdapterRegistry

Field Detail

messageReadersback to summary
private final List<HttpMessageReader<?>> messageReaders
SUPPORTED_METHODSback to summary
private static final Set<HttpMethod> SUPPORTED_METHODS

Constructor Detail

AbstractMessageReaderArgumentResolverback to summary
protected AbstractMessageReaderArgumentResolver(List<HttpMessageReader<?>> readers)

Constructor with HttpMessageReader's and a Validator.

Parameters
readers:List<HttpMessageReader<?>>

the readers to convert from the request body

AbstractMessageReaderArgumentResolverback to summary
protected AbstractMessageReaderArgumentResolver(List<HttpMessageReader<?>> messageReaders, ReactiveAdapterRegistry adapterRegistry)

Constructor that also accepts a ReactiveAdapterRegistry.

Parameters
messageReaders:List<HttpMessageReader<?>>

readers to convert from the request body

adapterRegistry:ReactiveAdapterRegistry

for adapting to other reactive types from Flux and Mono

Method Detail

extractValidationHintsback to summary
private Object[] extractValidationHints(MethodParameter parameter)

Check if the given MethodParameter requires validation and if so return a (possibly empty) Object[] with validation hints. A return value of null indicates that validation is not required.

Annotations
@Nullable
getMessageReadersback to summary
public List<HttpMessageReader<?>> getMessageReaders()

Return the configured message converters.

getSupportedMediaTypesback to summary
private List<MediaType> getSupportedMediaTypes(ResolvableType elementType)
handleMissingBodyback to summary
private ServerWebInputException handleMissingBody(MethodParameter parameter)
handleReadErrorback to summary
private Throwable handleReadError(MethodParameter parameter, Throwable ex)
readBodyback to summary
protected Mono<Object> readBody(MethodParameter bodyParameter, boolean isBodyRequired, BindingContext bindingContext, ServerWebExchange exchange)

Read the body from a method argument with HttpMessageReader.

Parameters
bodyParameter:MethodParameter

the MethodParameter to read

isBodyRequired:boolean

true if the body is required

bindingContext:BindingContext

the binding context to use

exchange:ServerWebExchange

the current exchange

Returns:Mono<Object>

the body

See Also
readBody(MethodParameter, MethodParameter, boolean, BindingContext, ServerWebExchange)
readBodyback to summary
protected Mono<Object> readBody(MethodParameter bodyParam, MethodParameter actualParam, boolean isBodyRequired, BindingContext bindingContext, ServerWebExchange exchange)

Read the body from a method argument with HttpMessageReader.

Parameters
bodyParam:MethodParameter

represents the element type for the body

actualParam:MethodParameter

the actual method argument type; possibly different from bodyParam, e.g. for an HttpEntity argument

isBodyRequired:boolean

true if the body is required

bindingContext:BindingContext

the binding context to use

exchange:ServerWebExchange

the current exchange

Returns:Mono<Object>

a Mono with the value to use for the method argument

Since
5.0.2
validateback to summary
private void validate(Object target, Object[] validationHints, MethodParameter parameter, BindingContext binding, ServerWebExchange exchange)