10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Customizing JAXB Bindings<br />

Building and Running the UnmarshalValidate Example Using Ant<br />

To compile and run the Unmarshal Validate example using Ant, in a terminal window, go to<br />

the tut-install/javaeetutorial5/examples/jaxb/unmarshal-validate/ directory and type<br />

the following:<br />

ant runapp<br />

Customizing JAXB Bindings<br />

512<br />

<strong>The</strong> next part of this chapter describes several examples that build on the concepts<br />

demonstrated in the Basic examples.<br />

<strong>The</strong> goal of this section is to illustrate how to customize JAXB bindings by means of custom<br />

binding declarations made in either of two ways:<br />

■ As annotations made inline in an XML schema<br />

■ As statements in an external file passed to the JAXB binding compiler<br />

Unlike the examples in “Basic JAXB Examples” on page 509, which focus on the <strong>Java</strong> code in the<br />

respective Main.java class files, the examples here focus on customizations made to the XML<br />

schema before generating the schema-derived <strong>Java</strong> binding classes.<br />

Note – Although JAXB binding customizations must currently be made by hand, it is envisioned<br />

that a tool/wizard might eventually be written by Sun or a third party to make this process more<br />

automatic. One of the goals of the JAXB technology is to standardize the format of binding<br />

declarations, thereby making it possible to create customization tools and to provide a standard<br />

interchange format between JAXB implementations.<br />

This section just begins to scratch the surface of customizations you can make to JAXB bindings<br />

and validation methods. For more information, refer to the JAXB Specification<br />

(http://jcp.org/en/jsr/detail?id=222).<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!