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.

<strong>Java</strong>-to-Schema Examples<br />

538<br />

Schema Content Ordering in the Example<br />

<strong>The</strong> purchase order code example demonstrates the effects of schema content ordering using<br />

the @XmlAccessorOrder annotation at the package and class level, and the<br />

@XmlType.propOrder annotation on a class.<br />

Class package-info.java defines @XmlAccessorOrder to be ALPHABETICAL for the package.<br />

<strong>The</strong> public fields shipTo and billTo in class PurchaseOrderType will be affected in the<br />

generated schema content order by this rule. Class USAddress defines the @XmlType.propOrder<br />

annotation on the class. User of this annotation demonstrates user-defined property order<br />

superseding ALPHABETICAL order in the generated schema.<br />

<strong>The</strong> generated schema file can be found in the<br />

tut-install/javaeetutorial5/examples/jaxb/j2s-xmlAccessorOrder/build/schemas/<br />

directory.<br />

Building and Running the XmlAccessorOrder Example Using NetBeans<br />

IDE<br />

Follow these instructions to build and run the XmlAccessorOrder example on your Application<br />

Server instance using NetBeans IDE.<br />

1. In NetBeans IDE, select File→Open Project.<br />

2. In the Open Project dialog, navigate to tut-install/javaeetutorial5/examples/jaxb/.<br />

3. Select the j2s-xmlAccessorOrder folder.<br />

4. Select the Open as Main Project check box.<br />

5. Click Open Project.<br />

6. Right-click the j2s-xmlAccessorOrder project and select Run.<br />

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

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

tut-install/javaeetutorial5/examples/jaxb/j2s-xmlAccessorOrder/ directory and type the<br />

following:<br />

ant runapp<br />

XmlAdapter Field Example<br />

<strong>The</strong> XmlAdapter Field example demonstrates how to use the XmlAdapter interface and the<br />

@Xml<strong>Java</strong>TypeAdapter annotation to provide a custom mapping of XML content into and out<br />

of a HashMap (field) that uses an int as the key and a String as the value.<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!