Java Reference
In-Depth Information
Next, the serialVersionUID was ignored, which is intuitive given the fact that it is private,
but also given that static fields are not serialized as part of regular Java serialization. So even
if the field had not been private, its static status is enough to keep it from being generated into
the schema.
The standard schema type xs:dateTime was used to represent the java.util.Date object,
and schemagen kept the fields in the same order.
You can decorate your Java class with standard JAXB annotations in order to rearrange your
results a little. Here are the changes you'll make:
▪ Specify a different name for the generated file
▪ Specify a different name for the class
▪ Specify a namespace
▪ Make a global root element
▪ Keep your static field and maintain its value
Example 2-18 is the same file, but now with JAXB annotations to meet your new goals.
Example2-18.Product Java class annotated for schema generation
package com.soacookbook.ch02.schemagen;
import java.util.Date;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(namespace="com.soacookbook.ch02.schemagen",
name="Product2")
@XmlType(namespace="com.soacookbook.ch02.schemagen")
public class ProductAnnotated {
private static final long serialVersionUID = 12345L;
@XmlElement(defaultValue="1.0")
static String VERSION = "1.0";
private String name;
private Date mfrDate;
public ProductAnnotated() { }
Search WWH ::




Custom Search