February 29, 2012

GlassFish 3.1.2 is Full of MOXy (EclipseLink JAXB)

I am very happy to announce that EclipseLink JAXB (MOXy) is now a JAXB (JSR-222) provider in GlassFish 3.1.2.  I would like to thank the EclipseLink and GlassFish committers for all their hard work to make this happen.

In this post I will introduce how MOXy can be leveraged to create a JAX-WS service.  In future posts I will cover more of the extensions in greater detail.

GlassFish can be downloaded from the following link:

February 16, 2012

JAXB and Package Level XmlAdapters

The XmlAdapter mechanism in JAXB (JSR-222) allows an unmappable class to be converted to a mappable one.  An XmlAdapter can be registered with the @XmlJavaTypeAdapter at the field, property, type, or package level.  This post will focus on the scope of the XmlAdapter when registered at the package level.

February 11, 2012

Mapping an Arbitrary List of Objects using JAXB's @XmlAnyElement and XmlAdapter

The @XmlAnyElement annotation enables a property to handle arbitrary XML elements, and the XmlAdapter provides a way to convert an object that can not be mapped into one that can.  In this post we will combine these two mechanisms  to map a list of arbitrary objects.

This post will cover the following concepts:
  1. The @XmlAnyElement annotation
  2. A type level XmlAdapter
  3. Marshalling/Unmarshalling root level simple data types (i.e. String and Integer)
  4. Specifying a root element via JAXBElement
  5. Specifying the type to be unmarshalled on the Unmarshaller

February 9, 2012

JAXB's @XmlType and propOrder

In this post I will demonstrate how to use the propOrder property on the @XmlType annotation to control the ordering of XML elements.  I will also discuss the impact of @XmlAccessorType on how propOrder is configured.

February 6, 2012

JAXB and Inheritance - EclipseLink MOXy's @XmlClassExtractor

In a previous post I covered how JAXB's XmlAdapter could be leveraged to use a node unique to the subtype as the inheritance indicator.  In this post I'll demonstrate that if that node is an XML attribute, then EclipseLink JAXB (MOXy)'s @XmlClassExtractor could be leveraged to do the same thing in fewer lines of code.