AbstractMessageConverterMethodArgumentResolver (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.web.servlet.mvc.method.annotation

## Class AbstractMessageConverterMethodArgumentResolver

- java.lang.Object
- - org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver

- All Implemented Interfaces:
    HandlerMethodArgumentResolver
  Direct Known Subclasses:
    AbstractMessageConverterMethodProcessor, RequestPartMethodArgumentResolver

      public abstract class AbstractMessageConverterMethodArgumentResolver
      extends Object
      implements HandlerMethodArgumentResolver

  A base class for resolving method argument values by reading from the body of a request with `HttpMessageConverter`s.
  Since:
    3.1
  Author:
    Arjen Poutsma, Rossen Stoyanchev

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected List<MediaType>` | `allSupportedMediaTypes`
    `protected Log` | `logger`
    `protected List<HttpMessageConverter<?>>` | `messageConverters`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected ServletServerHttpRequest` | `createInputMessage(NativeWebRequest webRequest)` Creates a new `HttpInputMessage` from the given `NativeWebRequest`.
    `protected <T> Object` | `readWithMessageConverters(HttpInputMessage inputMessage, MethodParameter methodParam, Type targetType)` Creates the method argument value of the expected parameter type by reading from the given HttpInputMessage.
    `protected <T> Object` | `readWithMessageConverters(NativeWebRequest webRequest, MethodParameter methodParam, Type paramType)` Creates the method argument value of the expected parameter type by reading from the given request.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.web.method.support.HandlerMethodArgumentResolver

      `resolveArgument, supportsParameter`

- - ### Field Detail

    - #### logger

          protected final Log logger

    - #### messageConverters

          protected final List<HttpMessageConverter<?>> messageConverters

    - #### allSupportedMediaTypes

          protected final List<MediaType> allSupportedMediaTypes

  - ### Constructor Detail

    - #### AbstractMessageConverterMethodArgumentResolver

          public AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters)

  - ### Method Detail

    - #### readWithMessageConverters

          protected <T> Object readWithMessageConverters(NativeWebRequest webRequest,
                                             MethodParameter methodParam,
                                             Type paramType)
                                              throws IOException,
                                                     HttpMediaTypeNotSupportedException

      Creates the method argument value of the expected parameter type by reading from the given request.
      Type Parameters:
        `T` - the expected type of the argument value to be created
      Parameters:
        `webRequest` - the current request
        `methodParam` - the method argument
        `paramType` - the type of the argument value to be created
      Returns:
        the created method argument value
      Throws:
        `IOException` - if the reading from the request fails
        `HttpMediaTypeNotSupportedException` - if no suitable message converter is found

    - #### readWithMessageConverters

          protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage,
                                             MethodParameter methodParam,
                                             Type targetType)
                                              throws IOException,
                                                     HttpMediaTypeNotSupportedException

      Creates the method argument value of the expected parameter type by reading from the given HttpInputMessage.
      Type Parameters:
        `T` - the expected type of the argument value to be created
      Parameters:
        `inputMessage` - the HTTP input message representing the current request
        `methodParam` - the method argument
        `targetType` - the type of object to create, not necessarily the same as the method parameter type (e.g. for `HttpEntity<String>` method parameter the target type is String)
      Returns:
        the created method argument value
      Throws:
        `IOException` - if the reading from the request fails
        `HttpMediaTypeNotSupportedException` - if no suitable message converter is found

    - #### createInputMessage

          protected ServletServerHttpRequest createInputMessage(NativeWebRequest webRequest)

      Creates a new `HttpInputMessage` from the given `NativeWebRequest`.
      Parameters:
        `webRequest` - the web request to create an input message from
      Returns:
        the input message