All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.jackson.xml.JacksonXmlModule Maven / Gradle / Ivy

Go to download

Extension for Jackson (http://jackson.codehaus.org) to offer alternative support for serializing POJOs as XML and deserializing XML as pojos. Support implemented on top of Stax API (javax.xml.stream), by implementing core Jackson Streaming API types like JsonGenerator, JsonParser and JsonFactory. Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMapper).

There is a newer version: 0.6.2
Show newest version
package com.fasterxml.jackson.xml;

import org.codehaus.jackson.Version;
import org.codehaus.jackson.map.AnnotationIntrospector;
import org.codehaus.jackson.map.module.SimpleModule;

import com.fasterxml.jackson.xml.ser.XmlBeanSerializerModifier;

/**
 * Module that implements most functionality needed to support producing and
 * consuming XML instead of JSON.
 */
public class JacksonXmlModule extends SimpleModule
{
    private final static AnnotationIntrospector XML_ANNOTATION_INTROSPECTOR = new JacksonXmlAnnotationIntrospector();

    // !!! TODO: how to externalize version?
    private final static Version VERSION = new Version(0, 1, 0, null);
    
    public JacksonXmlModule()
    {
        super("JackxonXmlModule", VERSION);
    }
    
    @Override
    public void setupModule(SetupContext context)
    {
        // Need to modify BeanSerializer that is used
        context.addBeanSerializerModifier(new XmlBeanSerializerModifier());
        // as well as AnnotationIntrospector
        context.insertAnnotationIntrospector(XML_ANNOTATION_INTROSPECTOR);
    }    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy