Hi,
Please evaluate this simple example and let me know if this is a real problem or something that I am doing wrong before I open a problem report.
Here's the pertinent schema:
<!--
// Task Status.
-->
<xs:complexType name="TaskStatusType">
<xs:complexContent>
<xs:extension base="tns:ExecutionStatusType">
<xs:sequence>
<xs:element name="CompletionCode" type="tns:CompletionCodeType">
<xs:annotation>
<xs:documentation>The completion code for this task.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Exception" type="xs:string">
<xs:annotation>
<xs:documentation>An exception message if the completion code states that an exception occurred.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!--
// Job Status.
-->
<xs:element name="JobStatus" type="tns:JobStatusType"/>
<xs:complexType name="JobStatusType">
<xs:complexContent>
<xs:extension base="tns:ExecutionStatusType">
<xs:sequence>
<xs:element name="TaskStatuses">
<xs:annotation>
<xs:documentation>List of task statuses.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="TaskStatus" type="tns:TaskStatusType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Here's the pertinent language binding:
<jaxb:bindings node="//xs:complexType[@name='JobStatusType']">
<jaxb:class implClass="com.sas.svcs.jobexecution.client.JobStatus"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:complexType[@name='TaskStatusType']">
<jaxb:class implClass="com.sas.svcs.jobexecution.client.TaskStatus"/>
</jaxb:bindings>
So, JAXB runtime will instantiate a JobStatus class for JobStatusType complex types. Ofcourse, my handwritten JobStatus class extends the generated JobStatusType class. Similarly, the TaskStatus class will be instantiated for TaskStatus complex types and likewise, the handwritten TaskStatus class extends the generated TaskStatusType class.
The generated JobStatusType class looks like the following:
package com.sas.svcs.jobexecution.client.jaxb;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.sas.svcs.jobexecution.client.ExecutionStatus;
/**
* <p>Java class for JobStatusType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="JobStatusType">
* <complexContent>
* <extension base="{
http://www.sas.com/xml/schema/sas-svcs/jobexecutionservice}ExecutionStatusType">
* <sequence>
* <element name="TaskStatuses">
* <complexType>
* <complexContent>
* <restriction base="{
http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="TaskStatus" type="{
http://www.sas.com/xml/schema/sas-svcs/jobexecutionservice}TaskStatusType" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "JobStatusType", propOrder = {
"taskStatuses"
})
public class JobStatusType
extends ExecutionStatus
implements Serializable
{
private final static long serialVersionUID = 1L;
@XmlElement(name = "TaskStatuses", required = true)
protected TaskStatuses taskStatuses;
/**
* Gets the value of the taskStatuses property.
*
* @return
* possible object is
* {_at_link TaskStatuses }
*
*/
public TaskStatuses getTaskStatuses() {
return taskStatuses;
}
/**
* Sets the value of the taskStatuses property.
*
* @param value
* allowed object is
* {_at_link TaskStatuses }
*
*/
public void setTaskStatuses(TaskStatuses value) {
this.taskStatuses = value;
}
}
Nothing interesting here. But, look further at the TaskStatuses generated class:
package com.sas.svcs.jobexecution.client.jaxb;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.sas.svcs.jobexecution.client.TaskStatus;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{
http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="TaskStatus" type="{
http://www.sas.com/xml/schema/sas-svcs/jobexecutionservice}TaskStatusType" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"taskStatus"
})
public class TaskStatuses
implements Serializable
{
private final static long serialVersionUID = 1L;
@XmlElement(name = "TaskStatus", required = true, type = TaskStatus.class)
protected List<TaskStatusType> taskStatus;
/**
* Gets the value of the taskStatus property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the taskStatus property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTaskStatus().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {_at_link TaskStatusType }
*
*
*/
public List<TaskStatusType> getTaskStatus() {
if (taskStatus == null) {
taskStatus = new ArrayList<TaskStatusType>();
}
return this.taskStatus;
}
}
Notice that it is returning List<TaskStatusType>. It should be returning List<TaskStatus> instead since TaskStatus is the implementation class. Right?
Please advise.
I've seen this work in some circumstances. That is, return the class specified via the jaxb:class implClass="" attribute.
Not sure what I am missing.
Thanks.
-Tony
Tony Dean
SAS Institute Inc.
919.531.6704
tony.dean_at_sas.com
SAS... The Power to Know
http://www.sas.com