Example usage for org.springframework.http.converter.xml MarshallingHttpMessageConverter MarshallingHttpMessageConverter

List of usage examples for org.springframework.http.converter.xml MarshallingHttpMessageConverter MarshallingHttpMessageConverter

Introduction

In this page you can find the example usage for org.springframework.http.converter.xml MarshallingHttpMessageConverter MarshallingHttpMessageConverter.

Prototype

public MarshallingHttpMessageConverter(Marshaller marshaller, Unmarshaller unmarshaller) 

Source Link

Document

Construct a new MarshallingMessageConverter with the given Marshaller and Unmarshaller .

Usage

From source file:org.springframework.social.soundcloud.api.impl.SoundCloudTemplate.java

@Override
protected List<HttpMessageConverter<?>> getMessageConverters() {
    List<HttpMessageConverter<?>> messageConverters = super.getMessageConverters();
    messageConverters.add(new ByteArrayHttpMessageConverter());
    XStreamMarshaller marshaller = new XStreamMarshaller();
    Map<Class<?>, String> implicitCollections = new HashMap<Class<?>, String>();
    implicitCollections.put(TrackArray.class, "tracks");
    marshaller.setImplicitCollections(implicitCollections);

    // marshaller.setConverters(converterMatchers);
    Map<String, Object> aliases = new HashMap<String, Object>();
    aliases.put("playlist", XmlPlaylistUpdate.class.getName());
    // aliases.put("playlist", PlaylistUpdate.class.getName());

    aliases.put("track", TrackReference.class.getName());

    Map<String, Class<?>> useAttributeFor = new HashMap<String, Class<?>>();
    useAttributeFor.put("type", String.class);

    try {//from w  w w  . ja  v a  2s  . com
        marshaller.setAliases(aliases);
        marshaller.setUseAttributeFor(useAttributeFor);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }

    messageConverters.add(new MarshallingHttpMessageConverter(marshaller, marshaller));
    return messageConverters;
}

From source file:org.bremersee.common.spring.autoconfigure.WebMvcConfiguration.java

@Bean
@Primary
public MarshallingHttpMessageConverter marshallingHttpMessageConverter() {
    return new MarshallingHttpMessageConverter(jaxbMarshaller, jaxbMarshaller);
}