public abstract class AbstractMessageConverterMethodProcessor extends AbstractMessageConverterMethodArgumentResolver implements HandlerMethodReturnValueHandler
AbstractMessageConverterMethodArgumentResolver
with the ability to handle
method return values by writing to the response with HttpMessageConverter
s.Modifier and Type | Field and Description |
---|---|
private ContentNegotiationManager |
contentNegotiationManager |
private static MediaType |
MEDIA_TYPE_APPLICATION |
allSupportedMediaTypes, logger, messageConverters
Modifier | Constructor and Description |
---|---|
protected |
AbstractMessageConverterMethodProcessor(java.util.List<HttpMessageConverter<?>> converters) |
protected |
AbstractMessageConverterMethodProcessor(java.util.List<HttpMessageConverter<?>> converters,
ContentNegotiationManager contentNegotiationManager) |
protected |
AbstractMessageConverterMethodProcessor(java.util.List<HttpMessageConverter<?>> converters,
ContentNegotiationManager manager,
java.util.List<java.lang.Object> requestResponseBodyAdvice) |
Modifier and Type | Method and Description |
---|---|
protected ServletServerHttpResponse |
createOutputMessage(NativeWebRequest webRequest)
Creates a new
HttpOutputMessage from the given NativeWebRequest . |
private java.util.List<MediaType> |
getAcceptableMediaTypes(HttpServletRequest request) |
private java.lang.reflect.Type |
getGenericType(MethodParameter returnType)
Return the generic type of the
returnType (or of the nested type if it is
a HttpEntity ). |
private MediaType |
getMostSpecificMediaType(MediaType acceptType,
MediaType produceType)
Return the more specific of the acceptable and the producible media types
with the q-value of the former.
|
protected java.util.List<MediaType> |
getProducibleMediaTypes(HttpServletRequest request,
java.lang.Class<?> returnValueClass) |
protected java.util.List<MediaType> |
getProducibleMediaTypes(HttpServletRequest request,
java.lang.Class<?> returnValueClass,
java.lang.reflect.Type returnValueType)
Returns the media types that can be produced:
The producible media types specified in the request mappings, or
Media types of configured converters that can write the specific return value, or
MediaType.ALL
|
protected java.lang.Class<?> |
getReturnValueType(java.lang.Object returnValue,
MethodParameter returnType)
Return the type of the value to be written to the response.
|
protected <T> void |
writeWithMessageConverters(T returnValue,
MethodParameter returnType,
NativeWebRequest webRequest)
Writes the given return value to the given web request.
|
protected <T> void |
writeWithMessageConverters(T returnValue,
MethodParameter returnType,
ServletServerHttpRequest inputMessage,
ServletServerHttpResponse outputMessage)
Writes the given return type to the given output message.
|
createInputMessage, getAdvice, isBindExceptionRequired, readWithMessageConverters, readWithMessageConverters, validateIfApplicable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handleReturnValue, supportsReturnType
resolveArgument, supportsParameter
private static final MediaType MEDIA_TYPE_APPLICATION
private final ContentNegotiationManager contentNegotiationManager
protected AbstractMessageConverterMethodProcessor(java.util.List<HttpMessageConverter<?>> converters)
protected AbstractMessageConverterMethodProcessor(java.util.List<HttpMessageConverter<?>> converters, ContentNegotiationManager contentNegotiationManager)
protected AbstractMessageConverterMethodProcessor(java.util.List<HttpMessageConverter<?>> converters, ContentNegotiationManager manager, java.util.List<java.lang.Object> requestResponseBodyAdvice)
protected ServletServerHttpResponse createOutputMessage(NativeWebRequest webRequest)
HttpOutputMessage
from the given NativeWebRequest
.webRequest
- the web request to create an output message fromprotected <T> void writeWithMessageConverters(T returnValue, MethodParameter returnType, NativeWebRequest webRequest) throws java.io.IOException, HttpMediaTypeNotAcceptableException
writeWithMessageConverters(Object, MethodParameter, ServletServerHttpRequest, ServletServerHttpResponse)
java.io.IOException
HttpMediaTypeNotAcceptableException
protected <T> void writeWithMessageConverters(T returnValue, MethodParameter returnType, ServletServerHttpRequest inputMessage, ServletServerHttpResponse outputMessage) throws java.io.IOException, HttpMediaTypeNotAcceptableException
returnValue
- the value to write to the output messagereturnType
- the type of the valueinputMessage
- the input messages. Used to inspect the Accept
header.outputMessage
- the output message to write tojava.io.IOException
- thrown in case of I/O errorsHttpMediaTypeNotAcceptableException
- thrown when the conditions indicated by Accept
header on
the request cannot be met by the message convertersprotected java.lang.Class<?> getReturnValueType(java.lang.Object returnValue, MethodParameter returnType)
ResponseEntity<T>
).private java.lang.reflect.Type getGenericType(MethodParameter returnType)
returnType
(or of the nested type if it is
a HttpEntity
).protected java.util.List<MediaType> getProducibleMediaTypes(HttpServletRequest request, java.lang.Class<?> returnValueClass)
protected java.util.List<MediaType> getProducibleMediaTypes(HttpServletRequest request, java.lang.Class<?> returnValueClass, java.lang.reflect.Type returnValueType)
MediaType.ALL
private java.util.List<MediaType> getAcceptableMediaTypes(HttpServletRequest request) throws HttpMediaTypeNotAcceptableException