Tutorial : Unmarshaling and Marshaling Data : Design
Design
OTN developers used the Oracle JAXB implementation to effectively
leverage an efficient and standard way to map between XML and Java code. Using
JAXB is more productive for Java developers, in that, they can afford to write
less code themselves and do not especially require XML expertise. Oracle provides
comprehensive support for the latest XML standards including JAXB through its
Oracle XDK 10g. The
JAXB class generator part of the Oracle XDK 10g
allows creation of Java classes based on the XML Schema.
OTN developers designed the user interface for the JAXBIPS
using the Java Swing API. The database information for all the customers' insurance
profile is stored in the JAXBIPS, which provides an option, of two datasources
- one being the filesystem, and the other being the database. It must be noted
that only one datasource can be active at any point in time. If the profile
information is stored in the filesystem, then the data is organized as flat
files, else, if it is stored in the XML DB, it is organized as XMLType tables.
The diagram below provides a high-level perspective of how the Marshaling and
Unmarshaling elements fit together in the design of the JAXBIPS application:
When data is retrieved from the FileSystem, it is validated at the time it
is loaded. In the case of data that is retrieved from the XML DB, the database
inherently associates the XMLType tables to a derived schema that performs the
validation. For data that is retrieved from the filesystem, its conversion into
Java objects are affected using the JAXB and the File Input/Output stream API's.
In the case of data that is retrieved from the XML DB, the StreamSource API's
are used for Marshaling and Unmarshaling data. JAXB provides a class generator
that creates Java classes that match with the element and attribute naming in
the respective XML documents.