When to Use JAXB


In Chapter 9, we hypothesized that developers would rarely deal with XML constructs directly in their application code when developing Web services, as a result of other JAX APIs. In Chapters 10 , 11, and 12, we looked how different APIs (such as JAX-RPC, JAXM, and JAXR, respectively) provide some of this abstraction. JAXB is intended to be used in cases where XML must be handled directly in application code. Some of the scenarios where JAXB would be appropriate typically involve applications that:

  • Read, write, or process XML-based configuration information.

  • Must pass XML data between applications independently of the SOAP-XML-based messaging and RPC protocol.

  • Persist data in XML format or read XML data from a persistent storage, such as an XML database. In such cases, JAXB can be used to marshall and unmarshall the XML directly into Java objects.

  • Access XML data and must update or modify that data at runtime. Rather than using SAX/DOM parsing, JAXB can be used to unmarshall the data to Java, change it as necessary, and marshall it back to the XML representation.

  • Must marshall value objects into XML and pass them between tiers.

The preceding is meant to be only an illustration of scenarios where JAXB may be appropriate and is not an exhaustive list.




Java Web Services Architecture
Java Web Services Architecture (The Morgan Kaufmann Series in Data Management Systems)
ISBN: 1558609008
EAN: 2147483647
Year: 2005
Pages: 210

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net