Java 类org.springframework.http.converter.AbstractHttpMessageConverter 实例源码

项目:carina    文件:RestTemplateBuilder.java   
public RestTemplateBuilder withSpecificJsonMessageConverter() {
    isUseDefaultJsonMessageConverter = false;

    AbstractHttpMessageConverter<?> jsonMessageConverter = new MappingJackson2HttpMessageConverter(
            Jackson2ObjectMapperBuilder
                    .json()
                    .featuresToEnable(
                               DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
                               DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)
                    .build());
    jsonMessageConverter.setSupportedMediaTypes(Lists.newArrayList(
            MediaType.TEXT_HTML, MediaType.TEXT_PLAIN,
            MediaType.APPLICATION_JSON));

    withMessageConverter(jsonMessageConverter);

    return this;
}
项目:spring4-understanding    文件:MappingJackson2XmlHttpMessageConverterTests.java   
private void writeInternal(Object object, HttpOutputMessage outputMessage) throws Exception {
    Method method = AbstractHttpMessageConverter.class.getDeclaredMethod(
            "writeInternal", Object.class, HttpOutputMessage.class);
    method.setAccessible(true);
    method.invoke(this.converter, object, outputMessage);
}