Java 类org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter 实例源码

项目:class-guard    文件:WebMvcConfigurationSupport.java   
/**
 * Adds a set of default HttpMessageConverter instances to the given list.
 * Subclasses can call this method from {@link #configureMessageConverters(List)}.
 * @param messageConverters the list to add the default message converters to
 */
protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
    StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
    stringConverter.setWriteAcceptCharset(false);

    messageConverters.add(new ByteArrayHttpMessageConverter());
    messageConverters.add(stringConverter);
    messageConverters.add(new ResourceHttpMessageConverter());
    messageConverters.add(new SourceHttpMessageConverter<Source>());
    messageConverters.add(new AllEncompassingFormHttpMessageConverter());

    if (romePresent) {
        messageConverters.add(new AtomFeedHttpMessageConverter());
        messageConverters.add(new RssChannelHttpMessageConverter());
    }
    if (jaxb2Present) {
        messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
    }
    if (jackson2Present) {
        messageConverters.add(new MappingJackson2HttpMessageConverter());
    }
    else if (jacksonPresent) {
        messageConverters.add(new MappingJacksonHttpMessageConverter());
    }
}
项目:lams    文件:RestTemplate.java   
/**
 * Create a new instance of the {@link RestTemplate} using default settings.
 * Default {@link HttpMessageConverter}s are initialized.
 */
@SuppressWarnings("deprecation")
public RestTemplate() {
    this.messageConverters.add(new ByteArrayHttpMessageConverter());
    this.messageConverters.add(new StringHttpMessageConverter());
    this.messageConverters.add(new ResourceHttpMessageConverter());
    this.messageConverters.add(new SourceHttpMessageConverter<Source>());
    this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());

    if (romePresent) {
        this.messageConverters.add(new AtomFeedHttpMessageConverter());
        this.messageConverters.add(new RssChannelHttpMessageConverter());
    }
    if (jaxb2Present) {
        this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
    }
    if (jackson2Present) {
        this.messageConverters.add(new MappingJackson2HttpMessageConverter());
    }
    else if (jacksonPresent) {
        this.messageConverters.add(new org.springframework.http.converter.json.MappingJacksonHttpMessageConverter());
    }
}
项目:oma-riista-web    文件:WebMVCConfig.java   
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
    final MappingJackson2HttpMessageConverter jsonMessageConverter = jacksonMessageConverter();

    final StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
    stringHttpMessageConverter.setWriteAcceptCharset(false);

    messageConverters.add(new CSVMessageConverter());
    messageConverters.add(new ByteArrayHttpMessageConverter());
    messageConverters.add(stringHttpMessageConverter);
    messageConverters.add(new ResourceHttpMessageConverter());
    messageConverters.add(new SourceHttpMessageConverter<>());
    messageConverters.add(new AllEncompassingFormHttpMessageConverter());
    messageConverters.add(jsonMessageConverter);
    messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
}
项目:spring4-understanding    文件:AllEncompassingFormHttpMessageConverter.java   
public AllEncompassingFormHttpMessageConverter() {
    addPartConverter(new SourceHttpMessageConverter<Source>());

    if (jaxb2Present && !jackson2Present) {
        addPartConverter(new Jaxb2RootElementHttpMessageConverter());
    }

    if (jackson2Present) {
        addPartConverter(new MappingJackson2HttpMessageConverter());
    }
    else if (gsonPresent) {
        addPartConverter(new GsonHttpMessageConverter());
    }

    if (jackson2XmlPresent) {
        addPartConverter(new MappingJackson2XmlHttpMessageConverter());
    }
}
项目:spring4-understanding    文件:XpathRequestMatchersIntegrationTests.java   
@Before
public void setup() {

    List<Person> composers = Arrays.asList(
            new Person("Johann Sebastian Bach").setSomeDouble(21),
            new Person("Johannes Brahms").setSomeDouble(.0025),
            new Person("Edvard Grieg").setSomeDouble(1.6035),
            new Person("Robert Schumann").setSomeDouble(Double.NaN));

    List<Person> performers = Arrays.asList(
            new Person("Vladimir Ashkenazy").setSomeBoolean(false),
            new Person("Yehudi Menuhin").setSomeBoolean(true));

    this.people = new PeopleWrapper(composers, performers);

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    converters.add(new Jaxb2RootElementHttpMessageConverter());

    this.restTemplate = new RestTemplate();
    this.restTemplate.setMessageConverters(converters);

    this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
项目:spring4-understanding    文件:XmlContentRequestMatchersIntegrationTests.java   
@Before
public void setup() {

    List<Person> composers = Arrays.asList(
            new Person("Johann Sebastian Bach").setSomeDouble(21),
            new Person("Johannes Brahms").setSomeDouble(.0025),
            new Person("Edvard Grieg").setSomeDouble(1.6035),
            new Person("Robert Schumann").setSomeDouble(Double.NaN));

    this.people = new PeopleWrapper(composers);

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    converters.add(new Jaxb2RootElementHttpMessageConverter());

    this.restTemplate = new RestTemplate();
    this.restTemplate.setMessageConverters(converters);

    this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
项目:riptide    文件:ExecuteTest.java   
@Test
public void shouldFailIfNoConverterFoundForBodyOfUnknownContentType() {
    final MockSetup setup = new MockSetup("https://api.example.com", Collections.emptyList());
    final MockRestServiceServer server = setup.getServer();
    final Http unit = setup.getHttpBuilder()
            .converter(new Jaxb2RootElementHttpMessageConverter()).build();

    // we never actually make the request, but the mock server is doing some magic pre-actively
    server.expect(requestTo(url))
            .andRespond(withSuccess());

    exception.expect(RestClientException.class);
    exception.expectMessage("no suitable HttpMessageConverter found ");
    exception.expectMessage("org.zalando.riptide.model.Success");

    unit.delete(url)
            .body(new Success(true))
            .dispatch(contentType());

    server.verify();
}
项目:class-guard    文件:XpathRequestMatcherTests.java   
@Before
public void setup() {

    List<Person> composers = Arrays.asList(
            new Person("Johann Sebastian Bach").setSomeDouble(21),
            new Person("Johannes Brahms").setSomeDouble(.0025),
            new Person("Edvard Grieg").setSomeDouble(1.6035),
            new Person("Robert Schumann").setSomeDouble(Double.NaN));

    List<Person> performers = Arrays.asList(
            new Person("Vladimir Ashkenazy").setSomeBoolean(false),
            new Person("Yehudi Menuhin").setSomeBoolean(true));

    this.people = new PeopleWrapper(composers, performers);

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    converters.add(new Jaxb2RootElementHttpMessageConverter());

    this.restTemplate = new RestTemplate();
    this.restTemplate.setMessageConverters(converters);

    this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
项目:class-guard    文件:XmlContentRequestMatcherTests.java   
@Before
public void setup() {

    List<Person> composers = Arrays.asList(
            new Person("Johann Sebastian Bach").setSomeDouble(21),
            new Person("Johannes Brahms").setSomeDouble(.0025),
            new Person("Edvard Grieg").setSomeDouble(1.6035),
            new Person("Robert Schumann").setSomeDouble(Double.NaN));

    this.people = new PeopleWrapper(composers);

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    converters.add(new Jaxb2RootElementHttpMessageConverter());

    this.restTemplate = new RestTemplate();
    this.restTemplate.setMessageConverters(converters);

    this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
项目:spring4probe    文件:ViewOrderXmlIntegrationTest.java   
@Before
public void setup()
{
    MockitoAnnotations.initMocks(this);

    /*
     * mockMvc object is being set up to support both XML and JSON
     * 
     * runtime 'com.fasterxml.jackson.core:jackson-core:2.2.2'
     * 
     * runtime 'com.fasterxml.jackson.core:jackson-databind:2.2.2'
     * 
     * runtime 'javax.xml.bind:jaxb-api:2.2.9'
     */
    this.mockMvc = standaloneSetup(controller)
            .setMessageConverters(new MappingJackson2HttpMessageConverter(),
                    new Jaxb2RootElementHttpMessageConverter()).build();
}
项目:lams    文件:AllEncompassingFormHttpMessageConverter.java   
@SuppressWarnings("deprecation")
public AllEncompassingFormHttpMessageConverter() {
    addPartConverter(new SourceHttpMessageConverter<Source>());
    if (jaxb2Present) {
        addPartConverter(new Jaxb2RootElementHttpMessageConverter());
    }
    if (jackson2Present) {
        addPartConverter(new MappingJackson2HttpMessageConverter());
    }
    else if (jacksonPresent) {
        addPartConverter(new org.springframework.http.converter.json.MappingJacksonHttpMessageConverter());
    }
}
项目:FastBootWeixin    文件:WxInvokerConfiguration.java   
/**
 * 只考虑微信的消息转换,后期可以优化
 * 其实这里完全可以使用系统的Bean,但是这里我想特殊处理,只对微信消息做转换,所以定制化了几个converter
 *
 * @return dummy
 */
private HttpMessageConverters getDefaultWxMessageConverters() {
    StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
    stringConverter.setWriteAcceptCharset(false);
    MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
    Jaxb2RootElementHttpMessageConverter xmlConverter = new Jaxb2RootElementHttpMessageConverter();
    AllEncompassingFormHttpMessageConverter formConverter = new AllEncompassingFormHttpMessageConverter();
    ResourceHttpMessageConverter resourceConverter = new ResourceHttpMessageConverter();
    HttpMessageConverters wxMessageConverters = new HttpMessageConverters(stringConverter, jsonConverter, xmlConverter, formConverter, resourceConverter);
    return wxMessageConverters;
}
项目:spring4-understanding    文件:RestTemplate.java   
/**
 * Create a new instance of the {@link RestTemplate} using default settings.
 * Default {@link HttpMessageConverter}s are initialized.
 */
public RestTemplate() {
    this.messageConverters.add(new ByteArrayHttpMessageConverter());
    this.messageConverters.add(new StringHttpMessageConverter());
    this.messageConverters.add(new ResourceHttpMessageConverter());
    this.messageConverters.add(new SourceHttpMessageConverter<Source>());
    this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());

    if (romePresent) {
        this.messageConverters.add(new AtomFeedHttpMessageConverter());
        this.messageConverters.add(new RssChannelHttpMessageConverter());
    }

    if (jackson2XmlPresent) {
        this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
    }
    else if (jaxb2Present) {
        this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
    }

    if (jackson2Present) {
        this.messageConverters.add(new MappingJackson2HttpMessageConverter());
    }
    else if (gsonPresent) {
        this.messageConverters.add(new GsonHttpMessageConverter());
    }
}
项目:documentum-rest-client-java    文件:DCTMJaxbClient.java   
@Override
protected void initRestTemplate(RestTemplate restTemplate) {
    super.initRestTemplate(restTemplate);
    restTemplate.setErrorHandler(new DCTMJaxbErrorHandler(restTemplate.getMessageConverters()));
    for(HttpMessageConverter<?> c : restTemplate.getMessageConverters()) {
        if(c instanceof FormHttpMessageConverter) {
            ((FormHttpMessageConverter)c).addPartConverter(new Jaxb2RootElementHttpMessageConverter());
            break;
        }
    }
}
项目:web-harvester    文件:ApiConfiguration.java   
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
    converter.setObjectMapper(objectMapperBuilder().build());

    converters.add(new Jaxb2RootElementHttpMessageConverter());
    converters.add(new Jaxb2CollectionHttpMessageConverter<>());
    converters.add(converter);
    super.configureMessageConverters(converters);
}
项目:cross-preferences    文件:Config.java   
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    converters.add(new MappingJackson2HttpMessageConverter());
    converters.add(new Jaxb2RootElementHttpMessageConverter());
    converters.add(new Jaxb2CollectionHttpMessageConverter<>());
    converters.add(new HtmlMessageConverter());
}
项目:sdk-rest    文件:RestTemplateFactory.java   
private static RestTemplate createRestTemplate() {
    List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
    messageConverters.add(new ByteArrayHttpMessageConverter());
    messageConverters.add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
    messageConverters.add(new ResourceHttpMessageConverter());
    messageConverters.add(new SourceHttpMessageConverter<Source>());
    messageConverters.add(new AllEncompassingFormHttpMessageConverter());
    messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
    messageConverters.add(new MappingJackson2HttpMessageConverter());

    return new RestTemplate(messageConverters);
}
项目:spring-social-naver    文件:NaverOAuth2ApiBinding.java   
public NaverOAuth2ApiBinding(final String accessToken) {
    super(accessToken);
    super.setRequestFactory(ClientHttpRequestFactorySelector.bufferRequests(getRestTemplate().getRequestFactory()));

    // set interceptors
    getRestTemplate().setInterceptors(Arrays.asList(new ClientHttpRequestInterceptor[]{new AdminKeyHeaderOAuth2RequestInterceptor(accessToken)}));

    // set xml->class http message converters
    getRestTemplate().setMessageConverters(Arrays.asList(new HttpMessageConverter<?>[]{new Jaxb2RootElementHttpMessageConverter()}));

    // init api operations
    userOperation = new UserOperationImpl(getRestTemplate(), isAuthorized());
}
项目:Novie    文件:ContextConfig.java   
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {

    converters.add(new StringHttpMessageConverter());
    converters.add(new Jaxb2RootElementHttpMessageConverter());
    converters.add(new MappingJacksonHttpMessageConverter());
    converters.add(new ReportCsvMessageConverter());
}
项目:class-guard    文件:AnnotationDrivenBeanDefinitionParser.java   
private ManagedList<?> getMessageConverters(Element element, Object source, ParserContext parserContext) {
    Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters");
    ManagedList<? super Object> messageConverters = new ManagedList<Object>();
    if (convertersElement != null) {
        messageConverters.setSource(source);
        for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) {
            Object object = parserContext.getDelegate().parsePropertySubElement(beanElement, null);
            messageConverters.add(object);
        }
    }

    if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) {
        messageConverters.setSource(source);
        messageConverters.add(createConverterDefinition(ByteArrayHttpMessageConverter.class, source));

        RootBeanDefinition stringConverterDef = createConverterDefinition(StringHttpMessageConverter.class, source);
        stringConverterDef.getPropertyValues().add("writeAcceptCharset", false);
        messageConverters.add(stringConverterDef);

        messageConverters.add(createConverterDefinition(ResourceHttpMessageConverter.class, source));
        messageConverters.add(createConverterDefinition(SourceHttpMessageConverter.class, source));
        messageConverters.add(createConverterDefinition(AllEncompassingFormHttpMessageConverter.class, source));

        if (romePresent) {
            messageConverters.add(createConverterDefinition(AtomFeedHttpMessageConverter.class, source));
            messageConverters.add(createConverterDefinition(RssChannelHttpMessageConverter.class, source));
        }
        if (jaxb2Present) {
            messageConverters.add(createConverterDefinition(Jaxb2RootElementHttpMessageConverter.class, source));
        }
        if (jackson2Present) {
            messageConverters.add(createConverterDefinition(MappingJackson2HttpMessageConverter.class, source));
        }
        else if (jacksonPresent) {
            messageConverters.add(createConverterDefinition(MappingJacksonHttpMessageConverter.class, source));
        }
    }
    return messageConverters;
}
项目:class-guard    文件:RestTemplate.java   
/**
 * Create a new instance of the {@link RestTemplate} using default settings.
 * Default {@link HttpMessageConverter}s are initialized.
 */
public RestTemplate() {
    this.messageConverters.add(new ByteArrayHttpMessageConverter());
    this.messageConverters.add(new StringHttpMessageConverter());
    this.messageConverters.add(new ResourceHttpMessageConverter());
    this.messageConverters.add(new SourceHttpMessageConverter<Source>());
    this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());

    if (romePresent) {
        this.messageConverters.add(new AtomFeedHttpMessageConverter());
        this.messageConverters.add(new RssChannelHttpMessageConverter());
    }
    if (jaxb2Present) {
        this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
    }
    if (jackson2Present) {
        this.messageConverters.add(new MappingJackson2HttpMessageConverter());
    }
    else if (jacksonPresent) {
        this.messageConverters.add(new MappingJacksonHttpMessageConverter());
    }
}
项目:class-guard    文件:AllEncompassingFormHttpMessageConverter.java   
public AllEncompassingFormHttpMessageConverter() {
    addPartConverter(new SourceHttpMessageConverter());
    if (jaxb2Present) {
        addPartConverter(new Jaxb2RootElementHttpMessageConverter());
    }
    if (jackson2Present) {
        addPartConverter(new MappingJackson2HttpMessageConverter());
    }
    else if (jacksonPresent) {
        addPartConverter(new MappingJacksonHttpMessageConverter());
    }
}
项目:Homepage    文件:ViewOrderXmlIntegrationTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);

    this.mockMvc = standaloneSetup(controller).setMessageConverters(
            new MappingJackson2HttpMessageConverter(),
            new Jaxb2RootElementHttpMessageConverter()).build();
}
项目:molgenis    文件:HttpClientConfig.java   
private List<HttpMessageConverter<?>> converters()
{
    List<HttpMessageConverter<?>> result = Lists.newArrayList();
    result.add(new ByteArrayHttpMessageConverter());
    result.add(new StringHttpMessageConverter());
    result.add(new ResourceHttpMessageConverter());
    result.add(new SourceHttpMessageConverter<>());
    result.add(new AllEncompassingFormHttpMessageConverter());
    result.add(new Jaxb2RootElementHttpMessageConverter());
    result.add(gsonHttpMessageConverter);
    return result;
}
项目:ods-lodms-plugins    文件:RestFactory.java   
public static RestTemplate getRest() {
  RestTemplate rest = new RestTemplate();
  List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
  converters.add(new Jaxb2RootElementHttpMessageConverter());
  converters.add(new FormHttpMessageConverter());
  converters.add(new MappingJacksonHttpMessageConverter());
  rest.setMessageConverters(converters);
  return rest;
}
项目:on-demand-software    文件:ViewOrderXmlIntegrationTest.java   
@Before
public void setup() {
  MockitoAnnotations.initMocks(this);

  this.mockMvc = standaloneSetup(controller)
          .setMessageConverters(new MappingJackson2HttpMessageConverter(),
                                new Jaxb2RootElementHttpMessageConverter()).build();
}
项目:on-demand-software    文件:OrderStatusIntegrationTest.java   
@Before
public void setup() {
  MockitoAnnotations.initMocks(this);

  this.mockMvc = standaloneSetup(controller)
          .setMessageConverters(
                  new MappingJackson2HttpMessageConverter(),
                  new Jaxb2RootElementHttpMessageConverter()).build();
}
项目:put-it-to-rest    文件:HttpMessageConvertersOverrideTest.java   
@Bean
@Qualifier("example")
public ClientHttpMessageConverters exampleHttpMessageConverters() {
    return new ClientHttpMessageConverters(singletonList(new Jaxb2RootElementHttpMessageConverter()));
}
项目:put-it-to-rest    文件:HttpMessageConvertersOverrideTest.java   
@Test
public void shouldOverride() {
    assertThat(unit.getConverters(), contains(instanceOf(Jaxb2RootElementHttpMessageConverter.class)));
}
项目:riptide    文件:HttpMessageConvertersOverrideTest.java   
@Bean
@Qualifier("example")
public ClientHttpMessageConverters exampleHttpMessageConverters() {
    return new ClientHttpMessageConverters(singletonList(new Jaxb2RootElementHttpMessageConverter()));
}
项目:riptide    文件:HttpMessageConvertersOverrideTest.java   
@Test
public void shouldOverride() {
    assertThat(unit.getConverters(), contains(instanceOf(Jaxb2RootElementHttpMessageConverter.class)));
}
项目:moserp    文件:TestRestConfiguration.java   
private void filterXmlConverters(RestTemplate restTemplate) {
    Stream<HttpMessageConverter<?>> messageConverterStream = restTemplate.getMessageConverters().stream();
    Predicate<HttpMessageConverter<?>> noXmlConverters = httpMessageConverter -> !(httpMessageConverter instanceof Jaxb2RootElementHttpMessageConverter) && !(httpMessageConverter instanceof MappingJackson2XmlHttpMessageConverter);
    List<HttpMessageConverter<?>> filtered = messageConverterStream.filter(noXmlConverters).collect(Collectors.toList());
    restTemplate.setMessageConverters(filtered);
}
项目:bjug-querydsl    文件:WebConfig.java   
/**
 * JAXB converter
 * @return
 */
@Bean
public HttpMessageConverter<Object> jaxbConverter() {
    Jaxb2RootElementHttpMessageConverter converter = new Jaxb2RootElementHttpMessageConverter();
    return converter;
}