Dropwizard extension for high performance processing and validation of XML.
Uses:
- Jackson XML Provider Jackson XML Provider with woodstox under the hood.
- Hibernate Validator same Dropwizard validation behvaiour for XML
This project is built using Snap-CI to enable Continuous Delivery. There are no mysterious snapshots, every time the tests pass a new release tagged and uploaded to bintray, so you know exactly what you are pulling down.
Until 0.9.0, all versions are are pegged against Dropwizard's release number and try to use the same Jackson dependency to avoid conflicts. See above badges for latest version to use. The table below give an indication of dependencies:
Dropwizard-XML | Dropwizard | Jackson | Woodstox | Stax |
---|---|---|---|---|
0.7.1-X | 0.7.1 | 2.3.3 | 4.1.4 | 3.1.1 |
0.8.0-X | 0.8.0 | 2.5.1 | transitive | |
0.8.1-X | 0.8.1 | 2.5.2 | transitive | |
0.9.0-X | 0.9.0 | 2.6.3 | transitive |
After 0.9.0, the Dropwizard and Jackson dependencies are no longer bundled with this library. They are specified as
gradle compileOnly
scope (provided
scope in Maven). It is up to you to provide the correct Dropwizard version
and Jackson version combination in your classpath:
Dropwizard-XML | Provide Dropwizard | Provide Jackson |
---|---|---|
39 | 0.9.1, 0.9.2 | 2.6.3 |
39 | 0.9.3 | 2.6.7 |
41+ | 1.0.0+ | 2.7.5+ |
See dependencies below fore more details.
Dropwizard XML Provider is hosted by Bintray JCenter.
You can add the dependency to your project by Maven:
<repositories>
<repository>
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<dependency>
<groupId>com.yunspace.dropwizard</groupId>
<artifactId>dropwizard-xml</artifactId>
<version>${dropwizardXmlVersion}</version>
<scope>compile</scope>
</dependency>
<!-- provided dependencies -->
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>1.0.0-rc4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-xml-provider</artifactId>
<version>2.7.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.7.5</version>
<scope>compile</scope>
</dependency>
Or Gradle:
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile "com.yunspace.dropwizard:dropwizard-xml:${dropwizardXmlVersion}"
compile "io.dropwizard:dropwizard-core:1.0.0-rc4"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-xml-provider:2.7.5"
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.7.5"
}
If you are using versions lesser than Dropwizard 1.0.0
and Jackson 2.7.5
you need to add jackson-datatype-jdk7
Maven:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk7</artifactId>
<version>2.6.7</version>
<scope>compile</scope>
</dependency>
Gradle:
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk7:2.6.7"
Add the XMLBundle
bootstrap.addBundle(new XmlBundle());
Annotate your Resources:
@Produces(MediaType.APPLICATION_XML) @Consumes(MediaType.APPLICATION_XML)
Annotate your model POJO with jackson-dataformat-xml bindings:
@JacksonXmlRootElement @JacksonXmlProperty @JacksonXmlElementWrapper @JacksonXmlText
Use validation/ignore annotations as you would normally:
@NotNull @Min @JsonIgnore
You can further custom the behaviour of your XML Mapper by passing in a JacksonXmlModule:
bootstrap.addBundle(new XmlBundle(jacksonXmlModule));
Or enable various serialisation/deserialisation features
XmlBundle indentXmlBundle = new XmlBundle();
indentXmlBundle.getXmlMapper().enable(SerializationFeature.INDENT_OUTPUT);
bootstrap.addBundle(indentXmlBundle);
##Sample project See dropwizard-xml-example subproject.
Add support for aalto