The next package I want to visit is Castor, from the Exolab group. Like Zeus, Castor is a free, open source package that provides XML-to-Java data binding, as well as several other additional features discussed later. The project is hosted at http://castor.exolab.org and is one of the oldest data binding projects around. As a result, it has a lot of maturity, which provides stability and a rich feature set. On the downside, it was around long before JAXB, so there are some significant differences in how it functions as compared to JAXB. That said, it remains an excellent choice for data binding when JAXB support is not required.
Castor follows the basic process flow outlined in the first six chapters. However, like Zeus, it deviates from this basic path to support some additional feature sets. Furthermore, Castor was developed before JAXB was more than a twinkling in Sun’s eye and therefore had to come up with original solutions for many problems that are fairly standardized now. This section looks at how Castor deals with class generation, marshalling, and unmarshalling.
Class generation in
is handled through a utility class,
. This class functions much
like JAXB’s schema compiler (
DTDSourceGenerator class. As a result, you should already be familiar with how this process works. An input XML constraint set is supplied, along with several options like a Java package, a destination directory, ...