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.
Versions 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-SNAPSHOT | 2.5.3 | transitive |
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>${dropwizard-xml-version}</version>
<scope>compile</scope>
</dependency>
Or Gradle:
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile "com.yunspace.dropwizard:dropwizard-xml:${dropwizardXmlVersion"
}
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.