Red Hat Training
A Red Hat training course is available for JBoss Enterprise SOA Platform
16.3. Writing JAXB Annotation Introduction Configurations
The XSD for the configuration is available online at http://anonsvn.jboss.org/repos/jbossws/projects/jaxbintros/tags/1.0.0.GA/src/main/resources/jaxb-intros.xsd. (In your IDE, register this XSD against the http://www.jboss.org/xsd/jaxb/intros namespace.)
- @XmlType
- https://jaxb.dev.java.net/nonav/2.1.3/docs/api/javax/xml/bind/annotation/XmlType.html: This goes on the “Class” element.
- @XmlElement
- https://jaxb.dev.java.net/nonav/2.1.3/docs/api/javax/xml/bind/annotation/XmlElement.html: This goes on the “Field” and “Method” elements.
- @XmlAttribute
- https://jaxb.dev.java.net/nonav/2.1.3/docs/api/javax/xml/bind/annotation/XmlAttribute.html: This goes on the “Field” and “Method” elements.
The basic structure of the configuration file follows the that of a Java class (that is, a "Class" containing "Fields" and "Methods".) The <Class>, <Field> and <Method> elements all require a “name” attribute. This attribute provides the name of the class, field or method. This name attribute's value is able to support regular expressions. This allows a single annotation introduction configuration to be targeted at more than one class, field or member by, for example, setting the name-space for a field in a class, or for all classes in a package.
The Annotation Introduction configurations match exactly with the Annotation definitions themselves, with each annotation “element-value pair” represented by an attribute on the annotations introduction configuration. Use the XSD and your IDE to editing the configuration.
Here is an example:
<?xml version = "1.0" encoding = "UTF-8"?> <jaxb-intros xmlns="http://www.jboss.org/xsd/jaxb/intros"> <!-- The type namespaces on the customerOrder are different from the rest of the message... --> <Class name="com.activebpel.ordermanagement.CustomerOrder"> <XmlType propOrder="orderDate,name,address,items" /> <Field name="orderDate"> <XmlAttribute name="date" required="true" /> </Field> <Method name="getXYZ"> <XmlElement namespace="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager" nillable="true" /> </Method> </Class> <!-- More general namespace config for the rest of the message... --> <Class name="com.activebpel.ordermanagement.*"> <Method name="get.*"> <XmlElement namespace="http://ordermanagement.activebpel.com/jaws" /> </Method> </Class> </jaxb-intros>