On the Java.net website, you will find the JAXB 2.x Commons project , which contains a common set of JAXB
plugins, including 4 to decide what you are trying to achieve:
There are other plugins available that cover similar general aspects of Java
domain objects.
Configuration
In terms of XML Schema
configuration, you will add links as shown below:
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:basic="http://jaxb2-commons.dev.java.net/basic" xmlns:equals="http://jaxb2-commons.dev.java.net/basic/equals" xmlns:hashCode="http://jaxb2-commons.dev.java.net/basic/hashCode" xmlns:toString="http://jaxb2-commons.dev.java.net/basic/toString" jaxb:extensionBindingPrefixes="basic equals hashCode toString"> </xs:schema>
Additional options are available, such as defining object properties that should be ignored when creating an equals( that )
implementation, toString()
implementation, etc.
Java code generation
From a Java
perspective, plugins typically have generated classes that implement an interface
; as an example, generated classes that include the implementation of equals( that )
will implement the Equals interface.
The constructive approach used by plugins usually generates 2 implementation options:
- A simple / standard implementation, such as the
equals( that )
method (when using Equals Plugin
). - A more complex implementation, which includes the
locator
and strategy
parameters, which allows you to implement custom processing (if you want). To do this, you will see the signature of the method, for example: equals( thisLocator, thatLocator, that, strategy)
.
Build / Play Time
In terms of runtime, you should enable ja JAXB2 Basics Runtime and provide parameter options such as: -Xequals
, -XhashCode
or -XtoString
. Examples of using JAXB2 Basics from Ant
and Maven
are given in the examples, if you use any of them to perform assemblies, and more detailed information about the assembly is given in the JAXB2 Basics User Guide .
Sean Mickey Sep 01 '15 at 16:43 2015-09-01 16:43
source share