public abstract class AbstractMessageReaderArgumentResolver extends HandlerMethodArgumentResolverSupport
HttpMessageReader
.
Applies validation if the method argument is annotated with
@javax.validation.Valid
or
Validated
. Validation
failure results in an ServerWebInputException
.
Modifier and Type | Field and Description |
---|---|
private java.util.List<HttpMessageReader<?>> |
messageReaders |
private static java.util.Set<HttpMethod> |
SUPPORTED_METHODS |
private java.util.List<MediaType> |
supportedMediaTypes |
logger
Modifier | Constructor and Description |
---|---|
protected |
AbstractMessageReaderArgumentResolver(java.util.List<HttpMessageReader<?>> readers)
Constructor with
HttpMessageReader 's and a Validator . |
protected |
AbstractMessageReaderArgumentResolver(java.util.List<HttpMessageReader<?>> messageReaders,
ReactiveAdapterRegistry adapterRegistry)
Constructor that also accepts a
ReactiveAdapterRegistry . |
Modifier and Type | Method and Description |
---|---|
private java.lang.Object[] |
extractValidationHints(MethodParameter parameter)
Check if the given MethodParameter requires validation and if so return
a (possibly empty) Object[] with validation hints.
|
java.util.List<HttpMessageReader<?>> |
getMessageReaders()
Return the configured message converters.
|
private ServerWebInputException |
handleMissingBody(MethodParameter parameter) |
private java.lang.Throwable |
handleReadError(MethodParameter parameter,
java.lang.Throwable ex) |
protected <any> |
readBody(MethodParameter bodyParameter,
boolean isBodyRequired,
BindingContext bindingContext,
ServerWebExchange exchange)
Read the body from a method argument with
HttpMessageReader . |
protected <any> |
readBody(MethodParameter bodyParam,
MethodParameter actualParam,
boolean isBodyRequired,
BindingContext bindingContext,
ServerWebExchange exchange)
Read the body from a method argument with
HttpMessageReader . |
private void |
validate(java.lang.Object target,
java.lang.Object[] validationHints,
MethodParameter param,
BindingContext binding,
ServerWebExchange exchange) |
checkAnnotatedParamNoReactiveWrapper, checkParameterType, checkParameterTypeNoReactiveWrapper, getAdapterRegistry
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
resolveArgument, supportsParameter
private static final java.util.Set<HttpMethod> SUPPORTED_METHODS
private final java.util.List<HttpMessageReader<?>> messageReaders
private final java.util.List<MediaType> supportedMediaTypes
protected AbstractMessageReaderArgumentResolver(java.util.List<HttpMessageReader<?>> readers)
HttpMessageReader
's and a Validator
.readers
- readers to convert from the request bodyprotected AbstractMessageReaderArgumentResolver(java.util.List<HttpMessageReader<?>> messageReaders, ReactiveAdapterRegistry adapterRegistry)
ReactiveAdapterRegistry
.messageReaders
- readers to convert from the request bodyadapterRegistry
- for adapting to other reactive types from Flux and Monopublic java.util.List<HttpMessageReader<?>> getMessageReaders()
protected <any> readBody(MethodParameter bodyParameter, boolean isBodyRequired, BindingContext bindingContext, ServerWebExchange exchange)
HttpMessageReader
.bodyParameter
- the MethodParameter
to readisBodyRequired
- true if the body is requiredbindingContext
- the binding context to useexchange
- the current exchangereadBody(MethodParameter, MethodParameter, boolean, BindingContext, ServerWebExchange)
protected <any> readBody(MethodParameter bodyParam, @Nullable MethodParameter actualParam, boolean isBodyRequired, BindingContext bindingContext, ServerWebExchange exchange)
HttpMessageReader
.bodyParam
- represents the element type for the bodyactualParam
- the actual method argument type; possibly different
from bodyParam
, e.g. for an HttpEntity
argumentisBodyRequired
- true if the body is requiredbindingContext
- the binding context to useexchange
- the current exchangeprivate java.lang.Throwable handleReadError(MethodParameter parameter, java.lang.Throwable ex)
private ServerWebInputException handleMissingBody(MethodParameter parameter)
@Nullable private java.lang.Object[] extractValidationHints(MethodParameter parameter)
null
indicates that validation is not required.private void validate(java.lang.Object target, java.lang.Object[] validationHints, MethodParameter param, BindingContext binding, ServerWebExchange exchange)