JavaTM Architecture for XML Binding
Developing JAXB RI Extensions

Specification Version: 2.0
Reference Implementation (RI) Version: 2.0 ea3

JAXB 2.0: Release Notes | XJC | XJCTask | SchemaGen | schemagenTask | Sample Apps | Changelog
JAXB 1.0.x: Release Notes | Changelog
JAXB RI Extensions: Runtime Properties | XJC Customizations | Develop Plugins
JAXB RI Schema Languages: W3C XML Schema | RELAX NG | DTD
JAXB Community: Java.net Homepage | Developer interest list | FAQ

This document describes how to write a JAXB RI plugin to extend the code generation of the JAXB RI.

What Can A Plugin Do?

A JAXB RI plugin participates in the code generation from a schema. It can define its own customizations that users can use to control it, it can access the code that the JAXB RI generates, and it can generate additional classes/methods/fields/annotations/comments.

As a show case of what a plugin can do, take a look at HyperJAXB and JAXB-verification projects.

Quick Start

To write a plugin, do the following simple steps.

  1. Write a class, say, org.acme.MyPlugin by extending com.sun.tools.xjc.Plugin. See javadoc for how to implement methods.
  2. Write the name of your plugin class in a text file and put it as /META-INF/services/com.sun.tools.xjc.Plugin in your jar file.

Users can then use your plugins by declaring an XJC ant task with your jar files.

<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
  <classpath>
    <fileset dir="jaxb-ri/lib" includes="*.jar" />
    <fileset dir="your-plugin" includes="*.jar" />
  </classpath>
</taskdef>

Resources

  1. Javadoc of XJC
  2. Javadoc of JAXB RI runtime
  3. the JAXB users mailing list for posting questions

Although we will do our best to maintain the compatibility of the interfaces, it is still subject to change at this point.