Magazine
 
Java Architecture for XML Binding

given XML schema to a set of generated Java classes).

II The binding runtime framework (which provides unmarshalling, marshalling, and validation functionalities).

Binding compiler:

This compiler binds the XML schema with the generated set of java classes. The JAXB binding compiler (or xjc) lets the developers generate Java classes from a chosen XML schema. The JAXB binding compiler transforms an XML schema into a collection of Java classes which matches the structure described in the XML schema. These classes are annotated with special JAXB annotations, which provide the runtime framework with the mappings it needs to process the corresponding XML documents.

Marshaller and unmarshaller together as a technology lets the Java developers easily manipulate XML data in the form of Java objects — without any need to know the details of the processing mechanisms of the parsers like SAX or DOM.

Binding runtime framework:

This framework provides support for marshalling, unmarshalling and the validation functionalities. Marshalling is the mechanism of placing data items before moving it over the communication channel. To unmarshall an XML document, you need to create an unmarshaller from the context. The unmarshaller processes the XML data from a wide variety of data sources, including files, input streams, URLs, DOM objects, SAX parsers, and more.

Marshalling involves transforming your Java classes into XML format. In JAXB 2.0, it’s simple to create and manipulate these Java classes. One can treat XML as an ordinary class (according to the corresponding XML schema).

Getting the things ready to go with JAXB
2.0:

 

1 Download the Java Web Services Developer Pack 2.0. It includes an implementation of JAXB 2.0.

2 Install JWSDP 2.0 at the location say C:\Sun\jwsdp-2.0 (which is the default installation directory). JAXB 2.0 will get installed in the directory C:Sun\jwsdp- 2.0\jaxb.

3 Include the path of the bin directory (i.e. C:\Sun\jwsdp-2.0\jaxb\bin) to the PATH variable.

4 Since JAXB 2.0 the parameterized types features of JDK5.0, so first install install the JDK 5.0 and then set the environment variables for the JAVA_HOME, JAXB_HOME and JAVA.

The following table lists the jar files required by JAXB 2.0.

JAR File Description
C:/Sun/jwsdp-2.0/jaxb/lib/jaxb-api.jar JAXB
2.0 API classes
C:/Sun/jwsdp-2.0/jaxb/lib/jaxb-impl.jarJAXB
2.0 implementation classes
C:/Sun/jwsdp-2.0/jaxb/lib/jaxb-xjc.jar JAXB
2.0 Compiler classes
C:/Sun/jwsdp-2.0/jwsdp-shared/lib/
activation.jar javax.activation package
classes.
C:/Sun/jwsdp-2.0/sjsxp/lib/jsr173_api.jar
StAX API classes
C:/Sun/jwsdp-2.0/sjsxp/lib/sjsxp.jar StAX
classes

JAXB prerequisites: To get started with JAXB 2.0 we require

• Java Platform and Standard Edition 5: JAXB 2.0 mainly based on the features of Java SE 5, like generics and annotations.

• Implementation of JAXB 2.0

We will implement JAXB 2.0 in the next issue.

SeptOct 2007 | Java Jazz Up | 49
 
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70, 71, 72, 73, 74, 75, 76, 77, 78,   Download PDF