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.

3. Select the inline-customize folder.<br />

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

5. Click Open Project.<br />

6. Right-click the inline-customize project and select Run.<br />

Building and Running the Customize Inline Example Using Ant<br />

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

tut-install/javaeetutorial5/examples/jaxb/inline-customize/ directory and type the<br />

following:<br />

ant runapp<br />

Key customizations in this sample, and the custom MyDatatypeConverter.java class, are<br />

described in more detail below.<br />

Customized Schema<br />

<strong>The</strong> customized schema used in the Customize Inline example is in the file<br />

tut-install/javaeetutorial5/examples/jaxb/inline-customize/po.xsd. <strong>The</strong><br />

customizations are in the tags.<br />

Global Binding Declarations<br />

<strong>The</strong> code below shows the globalBindings declarations in po.xsd:<br />

<br />

In this example, all values are set to the defaults except for collectionType.<br />

Customizing JAXB Bindings<br />

■ Setting fixedAttributeAsConstantProperty to true indicates that all fixed attributes<br />

should be bound to <strong>Java</strong> constants. By default, fixed attributes are just mapped to either<br />

simple or collection property, whichever is more appropriate.<br />

■ Setting collectionType to java.util.Vector specifies that all lists in the generated<br />

implementation classes should be represented internally as vectors. Note that the class name<br />

you specify for collectionType must implement java.util.List and be callable by<br />

newInstance.<br />

Chapter 17 • Binding between XML Schema and <strong>Java</strong> Classes 525

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

Saved successfully!

Ooh no, something went wrong!