public abstract class AbstractMessageConverterMethodArgumentResolver
extends java.lang.Object
implements org.springframework.web.method.support.HandlerMethodArgumentResolver
HttpMessageConverter
s.Modifier and Type | Field and Description |
---|---|
protected java.util.List<org.springframework.http.MediaType> |
allSupportedMediaTypes |
protected Log |
logger |
protected java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> |
messageConverters |
Constructor and Description |
---|
AbstractMessageConverterMethodArgumentResolver(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters)
Basic constructor with converters only.
|
AbstractMessageConverterMethodArgumentResolver(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters,
java.util.List<java.lang.Object> requestResponseBodyAdvice)
Constructor with converters and
Request~ and ResponseBodyAdvice . |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
adaptArgumentIfNecessary(java.lang.Object arg,
org.springframework.core.MethodParameter parameter)
Adapt the given argument against the method parameter, if necessary.
|
protected org.springframework.http.server.ServletServerHttpRequest |
createInputMessage(org.springframework.web.context.request.NativeWebRequest webRequest)
Create a new
HttpInputMessage from the given NativeWebRequest . |
protected boolean |
isBindExceptionRequired(org.springframework.web.bind.WebDataBinder binder,
org.springframework.core.MethodParameter parameter)
Whether to raise a fatal bind exception on validation errors.
|
protected <T> java.lang.Object |
readWithMessageConverters(org.springframework.http.HttpInputMessage inputMessage,
org.springframework.core.MethodParameter parameter,
java.lang.reflect.Type targetType)
Create the method argument value of the expected parameter type by reading
from the given HttpInputMessage.
|
protected <T> java.lang.Object |
readWithMessageConverters(org.springframework.web.context.request.NativeWebRequest webRequest,
org.springframework.core.MethodParameter parameter,
java.lang.reflect.Type paramType)
Create the method argument value of the expected parameter type by
reading from the given request.
|
protected void |
validateIfApplicable(org.springframework.web.bind.WebDataBinder binder,
org.springframework.core.MethodParameter parameter)
Validate the binding target if applicable.
|
protected final Log logger
protected final java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters
protected final java.util.List<org.springframework.http.MediaType> allSupportedMediaTypes
public AbstractMessageConverterMethodArgumentResolver(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters)
public AbstractMessageConverterMethodArgumentResolver(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters, @Nullable java.util.List<java.lang.Object> requestResponseBodyAdvice)
Request~
and ResponseBodyAdvice
.@Nullable protected <T> java.lang.Object readWithMessageConverters(org.springframework.web.context.request.NativeWebRequest webRequest, org.springframework.core.MethodParameter parameter, java.lang.reflect.Type paramType) throws java.io.IOException, org.springframework.web.HttpMediaTypeNotSupportedException, org.springframework.http.converter.HttpMessageNotReadableException
T
- the expected type of the argument value to be createdwebRequest
- the current requestparameter
- the method parameter descriptor (may be null
)paramType
- the type of the argument value to be createdjava.io.IOException
- if the reading from the request failsorg.springframework.web.HttpMediaTypeNotSupportedException
- if no suitable message converter is foundorg.springframework.http.converter.HttpMessageNotReadableException
@Nullable protected <T> java.lang.Object readWithMessageConverters(org.springframework.http.HttpInputMessage inputMessage, org.springframework.core.MethodParameter parameter, java.lang.reflect.Type targetType) throws java.io.IOException, org.springframework.web.HttpMediaTypeNotSupportedException, org.springframework.http.converter.HttpMessageNotReadableException
T
- the expected type of the argument value to be createdinputMessage
- the HTTP input message representing the current requestparameter
- the method parameter descriptortargetType
- the target type, not necessarily the same as the method
parameter type, e.g. for HttpEntity<String>
.java.io.IOException
- if the reading from the request failsorg.springframework.web.HttpMediaTypeNotSupportedException
- if no suitable message converter is foundorg.springframework.http.converter.HttpMessageNotReadableException
protected org.springframework.http.server.ServletServerHttpRequest createInputMessage(org.springframework.web.context.request.NativeWebRequest webRequest)
HttpInputMessage
from the given NativeWebRequest
.webRequest
- the web request to create an input message fromprotected void validateIfApplicable(org.springframework.web.bind.WebDataBinder binder, org.springframework.core.MethodParameter parameter)
The default implementation checks for @javax.validation.Valid
,
Spring's Validated
,
and custom annotations whose name starts with "Valid".
binder
- the DataBinder to be usedparameter
- the method parameter descriptorisBindExceptionRequired(org.springframework.web.bind.WebDataBinder, org.springframework.core.MethodParameter)
protected boolean isBindExceptionRequired(org.springframework.web.bind.WebDataBinder binder, org.springframework.core.MethodParameter parameter)
binder
- the data binder used to perform data bindingparameter
- the method parameter descriptortrue
if the next method argument is not of type Errors
@Nullable protected java.lang.Object adaptArgumentIfNecessary(@Nullable java.lang.Object arg, org.springframework.core.MethodParameter parameter)
arg
- the resolved argumentparameter
- the method parameter descriptor