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.

-help Display a brief summary of the compiler switches.<br />

-version Display the compiler version information.<br />

-Xlocator Enable source location support for generated code.<br />

-Xsync-methods Generate accessor methods with the synchronized keyword.<br />

-mark-generated Mark the generated code with the -@javax.annotation.Generated<br />

annotation.<br />

JAXB Schema Generator Option<br />

<strong>The</strong> JAXB Schema Generator, schemagen, creates a schema file for each namespace referenced<br />

in your <strong>Java</strong> classes. <strong>The</strong> schema generator can be launched using the appropriate schemagen<br />

shell script in the bin directory for your platform. <strong>The</strong> schema generator processes <strong>Java</strong> source<br />

files only. If your <strong>Java</strong> sources reference other classes, those sources must be accessible from<br />

your system CLASSPATH environment variable, otherwise errors will occur when the schema<br />

is generated. <strong>The</strong>re is no way to control the name of the generated schema files.<br />

You can display quick usage instructions by invoking the scripts without any options, or with<br />

the -help option. <strong>The</strong> syntax is as follows:<br />

schemagen [-d path] [java-source-files]<br />

<strong>The</strong> -d path option specifies the location of the processor- and javac-generated class files.<br />

About the Schema-to-<strong>Java</strong> Bindings<br />

When you run the JAXB binding compiler against the po.xsd XML schema used in the basic<br />

examples (Unmarshal Read, Modify Marshal, Unmarshal Validate), the JAXB binding compiler<br />

generates a <strong>Java</strong> package named primer.po containing 11 classes, making a total of 12 classes in<br />

each of the basic examples, as described in Table 17–12.<br />

TABLE 17–12 Schema-Derived JAXB Classes in the Basic Examples<br />

Class Description<br />

JAXB Examples<br />

primer/po/Comment.java Public interface extending javax.xml.bind.Element;<br />

binds to the global schema element named comment.<br />

Note that JAXB generates element interfaces for all global<br />

element declarations.<br />

primer/po/Items.java Public interface that binds to the schema complexType<br />

named Items.<br />

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

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

Saved successfully!

Ooh no, something went wrong!