Child pages
  • Purchase Order Sample
Skip to end of metadata
Go to start of metadata

Purchase order sample demonstrates the usage of AnnoxAnnotationReader with classes based on the well-known purchase order schema from the XML Schema Primer.

The task is as follows. We have a number of Java classes which represent the purchase order schema. The goal is to make them work with JAXB without annotating them.

Here's how to solve this task.

First of all we need to create XML resources for our classes. In this sample we have the following classes:

  • org.jvnet.annox.samples.po.ObjectFactory;
  • org.jvnet.annox.samples.po.PurchaseOrderType;
  • org.jvnet.annox.samples.po.Items;
  • org.jvnet.annox.samples.po.USAddress;
  • org.jvnet.annox.samples.po.Items$Item.

For demonstration purposes I'll put definitions for the first four classes in a common org/jvnet/annox/samples/po/package-info.ann.xml resource and the last class in his own org/jvnet/annox/samples/po/Items$Item.ann.xml resource.

To read annotations from these XML resource I only need to configure JAXB context with an instance of the AnnoxAnnotationReader:

You may download the Ant or Maven distribution of the purchase order sample from the download page.

  • No labels