Introduction to Spring OXM:-
Spring OXM stands for Spring Object XML Mappers and it is a module
available in Spring to ease the mapping between java objects and XML documents.
The module is extensible and hence it provides integration with various
popular frameworks like Castor, JAXB, XmlBeans and XStream.
An O/X-Mapper allows you to map Java objects to XML-Data and
XML-Data to Java objects. This is also known as XML-Marshalling or
XML-Serialization and is absolutely no new invention.
Some of the benefits of using Spring for your O/X mapping needs are:
There are some advantages of OXM as follows
1 Ease of configuration
Spring’s bean factory makes it easy to configure marshallers, without
needing to construct JAXB context, JiBX binding factories, etc.
The marshallers can be configured as any other bean in your application context.
Additionally, XML Schema-based configuration is available for a number of
marshallers, making the configuration even simpler.
2 Consistent Interfaces
Spring’s O/X mapping operates through two global interfaces: the Marshaller
and Unmarshaller interface. These abstractions allow you to switch O/X
mapping frameworks with relative ease, with little or no changes required
on the classes that do the marshalling.
3 Consistent Exception Hierarchy
Spring provides a conversion from exceptions from the underlying O/X mapping
tool to its own exception hierarchy with the XmlMappingException as the
root exception. As can be expected, these runtime exceptions wrap the original
exception so no information is lost.