Tutorial : Unmarshaling and Marshaling Data : Concepts
Discuss this tutorial. Printable version (PDF).
Go to Contents page. Go to previous page. Go up a level. Go to next page.

 

 

Concepts


Understanding the following concepts will help you work through the remainder of this tutorial, and better appreciate the design and implementation decisions that OTN developers applied to the JAXBIPS sample application:

About JAXB

Java Architecture for XML Binding (JAXB) provides API and tools that make it easier to use Java applications that read, process and output XML data. JAXB features a newer approach, and an easier way of authoring and processing XML compared to SAX or DOM, by automating the mapping between XML documents and Java objects. JAXB makes XML easy to use by compiling an XML schema into one or more Java technology classes. The combination of the schema derived classes and the binding framework enable one to perform the following operations on an XML document:

  • Unmarshal XML content into a Java object representation.
  • Access, update and validate the Java representation against schema constraints
  • Marshal the Java representation of the XML content into XML content
  • Some of the advantages associated with using the JAXB framework include:

  • Efficient Mechanism: JAXB provides an efficient mechanism for Java developers to simplify the creation and maintenance of XML-enabled Java applications.

  • Increased Productivity: Java developers using JAXB are more productive because they are free from the burden of writing complex parsing code.

    About Unmarshaling

    Unmarshaling, in data binding terms, refers to the conversion of XML documents to Java object instances. To better understand the concepts of Unmarshaling and Marshaling, one has to understand the key concepts behind Data binding and Class generation.

    Data binding refers to the mapping of XML documents to objects and vice-versa. Other Java and XML API's (such as SAX, DOM, dom4J, JAXP, etc) achieve the same thing, however they are document-centric, in that they are driven by data in some XML representation. Data binding, on the other hand is data-centric, and allows applications to manipulate data that has been serialized as XML, thereby driving the business priority of the application.

    Class generation refers to the generation of Java source files - it involves the mapping between a structure that is laid out by the constraints in an XML document and a set of Java classes. The Oracle JAXB implementation provides a JAXB class generator that takes a set of XML constraints as input and creates a set of Java source files. When these source files are compiled, you are ready to start the process of Unmarshaling.

    The Marshaling and Unmarshaling API's in the java.xml.bind package within the JAXB API affects the Unmarshaling process in the Insurance Profile System application. The Streamsource API's are used for unmarshaling data from the XMLType tables in the database. The XML document to be converted should be conformant with the structure of the generated Java classes.

    The block diagram below summarizes the flow of the unmarshaling process:


    Model - View - Controller

    About Marshaling

    Marshaling works in an opposite fashion to the Unmarshaling process - it converts a Java object into an XML document representation. Similar to the unmarshaling process, the generated Java classes must be validated, and checked for conformance with the existing Java classes before converting them into XML. As with the Unmarshaling process, the Marshaling and Unmarshaling API's in the java.xml.bind package within the JAXB API affects the marshaling process in the Insurance Profile System application.

    The block diagram below summarizes the flow of the Marshaling process:

    Model - View - Controller


    Discuss this tutorial. Printable version (PDF).
    Go to Contents page. Go to previous page. Go up a level. Go to next page.

  • E-mail this page
    Printer View Printer View
    Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy