JiBX
The JiBX framework offers a solution similar to that which Hibernate 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, see the JiBX web
site. The Spring integration classes reside in the org.springframework.oxm.jibx
package.
Using JibxMarshaller
The JibxMarshaller
class implements both the Marshaller
and Unmarshaller
interface. To operate, it requires the name of the class to marshal in, which you can
set using the targetClass
property. Optionally, you can set the binding name by setting the
bindingName
property. In the following example, 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>
...
</beans>
A JibxMarshaller
is configured for a single class. If you want to marshal multiple
classes, you have to configure multiple JibxMarshaller
instances with different targetClass
property values.
XML Configuration Namespace
The jibx-marshaller
tag configures a org.springframework.oxm.jibx.JibxMarshaller
,
as the following example shows:
<oxm:jibx-marshaller id="marshaller" target-class="org.springframework.ws.samples.airline.schema.Flight"/>
The following table describes the available attributes:
Attribute | Description | Required |
---|---|---|
|
The ID of the marshaller |
No |
|
The target class for this marshaller |
Yes |
|
The binding name used by this marshaller |
No |