The JiBX framework offers a solution similar to that which JDO provides for ORM: a binding definition defines the rules for how your Java objects are converted to or from XML. After preparing the binding and compiling the classes, a JiBX binding compiler enhances the class files, and adds code to handle converting instances of the classes from or to XML.
For more information on JiBX, refer to the JiBX web site. The Spring integration classes reside in the org.springframework.oxm.jibx package.
The JibxMarshaller
class implements both the
Marshaller
and Unmarshaller
interface.
To operate, it requires the name of the class to marshall in, which you can set using the
targetClass property. Optionally, you can set the binding name using the
bindingName property. In the next sample, we bind the
Flights
class:
<beans> <bean id="jibxFlightsMarshaller" class="org.springframework.oxm.jibx.JibxMarshaller"> <property name="targetClass">org.springframework.oxm.jibx.Flights</property> </bean> ...
A JibxMarshaller
is configured for a single class. If you want to marshal
multiple classes, you have to configure multiple JibxMarshaller
s with
different targetClass property values.
The jibx-marshaller
tag configures a org.springframework.oxm.jibx.JibxMarshaller
.
Here is an example:
<oxm:jibx-marshaller id="marshaller" target-class="org.springframework.ws.samples.airline.schema.Flight"/>
Available attributes are:
Attribute | Description | Required |
---|---|---|
id | the id of the marshaller | no |
target-class | the target class for this marshaller | yes |
bindingName | the binding name used by this marshaller | no |