Installing Upgrading Designing Configuring Deploying Monitoring Administering Troubleshooting Reference JBI Components
Close Print View
Designing: Understanding the JAXB Binding Process
 

Classic Java CAPS

Developing Java CAPS Projects

Using SOAP Message Handlers

Creating a Runtime Environment

Designing Business Processes in the Sun Business Process Manager

Working with TCP/IP HL7 Collaborations

Developing Sun Master Indexes (Repository)

Developing Sun Master Patient Indexes

Developing OTDs for Application Adapters

Developing OTDs for Communication Adapters

Developing OTDs for Database Adapters

Developing OTDs for Web Server Adapters

Designing with Application Adapters

Designing with Communication Adapters

Designing with Web Server Adapters

SWIFT Integration Projects

Java EE Based Components

Designing with Sun JCA Adapters

About the TCP/IP JCA Adapter

Defining Constants and Variables

Using Database Operations

Developing Sun Master Indexes

Using the JMS JCA Wizard

Using the JAXB Wizard and Code-Seeder Pallete

Understanding the JAXB Binding Process

To Perform a Typical JAXB Binding Process

The JAXB Wizard

Code-Seeder Palette (JAXB) Wizard Editor Palette Actions

Understanding the JAXB Binding Process

The JAXB APIs and tools are shipped in the jaxb subdirectory of the Java WSDP. This directory contains sample applications, a JAXB binding compiler (xjc), and implementations of the runtime binding framework APIs contained in the javax.xml.bind package. For more information on binding between XML Schema and Java Classes, refer to the following tutorial: http://java.sun.com/javaee/5/docs/tutorial/doc/bnazf.html.

To Perform a Typical JAXB Binding Process

The following steps demonstrate ONE particular way to bind XML schemas and Java representations. Depending on your requirements, the binding process can be achieved in several different ways..

  1. Generate JAXB classes.

    An XML schema is used as input to the JAXB binding compiler to generate JAXB classes based on that schema.

  2. Compile JAXB classes.

    All of the generated classes, source files, and application code must be compiled.

  3. Unmarshal XML documents.

    XML documents written according to the constraints in the source schema are unmarshalled by the JAXB binding framework.

    Note - JAXB also supports the unmarshalling of XML data from sources other than files/documents, such as DOM nodes, string buffers, and SAX Sources.

  4. Generate content tree.

    The unmarshalling process generates a content tree of data objects instantiated from the generated JAXB classes; this content tree represents the structure and content of the source XML documents.

  5. Validate source XML (optional).

    The unmarshalling process optionally involves validation of the source XML documents before generating the content tree.

    Note - If you modify the content tree in Step 6 (below), you can also use the JAXB Validate operation to validate the changes before marshalling the content back to an XML document.

  6. Process content.

    The client application can modify the XML data represented by the Java content tree by means of interfaces generated by the binding compiler.

  7. Marshal the content tree out to one or more XML output documents.

    The content may be validated before marshalling.

    To summarize, using JAXB involves two discrete sets of activities:

    • Generate and compile JAXB classes from a source schema, and build an application that implements these classes

    • Run the application to unmarshal, process, validate, and marshal XML content through the JAXB binding framework

    These two steps are usually performed at separate times in two distinct phases. Typically, there is an application development phase in which JAXB classes are generated and compiled, with a binding implementation being built. That is followed by a deployment phase in which the generated JAXB classes are used to process XML content in an ongoing live production setting.