Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/DesignDocs/317962/Phase3"
Line 29: | Line 29: | ||
| align="center" | X | | align="center" | X | ||
| align="center" | | | align="center" | | ||
− | | align="center" | | + | | align="center" | |
|} | |} | ||
− | == XmlDiscriminatorNode == | + | == Inheritance Support == |
− | === Purpose === | + | === XmlDiscriminatorNode === |
+ | ==== Purpose ==== | ||
Provide a means to set the class indicator field name when using inheritance. | Provide a means to set the class indicator field name when using inheritance. | ||
− | === Java Metadata === | + | ==== Java Metadata ==== |
<source lang="java"> | <source lang="java"> | ||
package org.eclipse.persistence.oxm.annotations; | package org.eclipse.persistence.oxm.annotations; | ||
Line 46: | Line 47: | ||
} | } | ||
</source> | </source> | ||
− | === XML Metadata === | + | ==== XML Metadata ==== |
− | ==== xml-discriminator-node ==== | + | ===== xml-discriminator-node ===== |
The <code>xml-discriminator-node</code> metadata tag will be used to set the class indicator field name when using inheritance. The value will be in the form of an XPath to an attribute, i.e. <code>@xsi:type</code>. | The <code>xml-discriminator-node</code> metadata tag will be used to set the class indicator field name when using inheritance. The value will be in the form of an XPath to an attribute, i.e. <code>@xsi:type</code>. | ||
− | ==== | + | === XmlDiscriminatorValue === |
+ | ==== Purpose ==== | ||
+ | Provide a means to set a class indicator when using inheritance. | ||
− | Following is the proposed XSD change necessary to provide | + | ==== Java Metadata ==== |
+ | <source lang="java"> | ||
+ | package org.eclipse.persistence.oxm.annotations; | ||
+ | |||
+ | @Target({TYPE}) | ||
+ | @Retention(RUNTIME) | ||
+ | public @interface XmlDiscriminatorValue { | ||
+ | String value(); | ||
+ | } | ||
+ | </source> | ||
+ | ==== XML Metadata ==== | ||
+ | ===== xml-discriminator-value ===== | ||
+ | The <code>xml-discriminator-value</code> metadata tag will be used to set a class indicator when using inheritance. | ||
+ | |||
+ | ==== XML Schema ==== | ||
+ | Following is the proposed XSD change necessary to provide support for inheritance: | ||
<source lang="xml"> | <source lang="xml"> | ||
<xs:element name="java-type"> | <xs:element name="java-type"> | ||
Line 76: | Line 94: | ||
<xs:attribute name="xml-customizer" type="xs:string" /> | <xs:attribute name="xml-customizer" type="xs:string" /> | ||
<xs:attribute name="xml-discriminator-node" type="xs:string" /> | <xs:attribute name="xml-discriminator-node" type="xs:string" /> | ||
+ | <xs:attribute name="xml-discriminator-value" type="xs:string" /> | ||
<xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" /> | <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" /> | ||
<xs:attribute name="xml-transient" type="xs:boolean" default="false" /> | <xs:attribute name="xml-transient" type="xs:boolean" default="false" /> | ||
Line 82: | Line 101: | ||
</source> | </source> | ||
− | === Example: === | + | ==== Example: ==== |
− | The following example will demonstrate how | + | The following example will demonstrate how inheritance can be configured. |
− | Using the <code>xml-discriminator-node</code> [http://wiki.eclipse.org/EclipseLink/DesignDocs/293925/MOXyExtensions EclipseLink XML metadata] | + | Using the <code>xml-discriminator-node</code> and <code>xml-discriminator-value</code> [http://wiki.eclipse.org/EclipseLink/DesignDocs/293925/MOXyExtensions EclipseLink XML metadata] tags to set the class indicator field name and class indicator(s) can be accomplished as follows: |
<source lang="xml"> | <source lang="xml"> | ||
− | <java-type name="org.example.Vehicle" xml-discriminator-node="@vtype"> | + | <java-types> |
− | + | <java-type name="org.example.Vehicle" xml-discriminator-node="@vtype" xml-discriminator-value="vehicle"> | |
− | </java-type> | + | <xml-root-element name="vehicle-data" /> |
+ | </java-type> | ||
+ | <java-type name="org.example.Car" xml-discriminator-value="car"> | ||
+ | <xml-root-element name="car-data" /> | ||
+ | </java-type> | ||
+ | <java-type name="org.example.SportsCar" xml-discriminator-value="sports-car"> | ||
+ | <xml-root-element name="sportscar-data" /> | ||
+ | </java-type> | ||
+ | </java-types> | ||
</source> | </source> | ||
− | Setting the class indicator field via Annotations would be accomplished as follows: | + | Setting the class indicator field name and class indicator(s) via Annotations would be accomplished as follows: |
org.example.Vehicle.java | org.example.Vehicle.java | ||
<source lang="java"> | <source lang="java"> | ||
Line 98: | Line 125: | ||
@XmlRootElement("vehicle-data") | @XmlRootElement("vehicle-data") | ||
@XmlDiscriminatorNode("@vtype") | @XmlDiscriminatorNode("@vtype") | ||
+ | @XmlDiscriminatorValue("vehicle") | ||
class Vehicle { | class Vehicle { | ||
public String model; | public String model; | ||
public String manufacturer; | public String manufacturer; | ||
public int topSpeed; | public int topSpeed; | ||
+ | } | ||
+ | </source> | ||
+ | org.example.Car.java | ||
+ | <source lang="java"> | ||
+ | package org.example; | ||
+ | |||
+ | @XmlRootElement("car-data") | ||
+ | @XmlDiscriminatorValue("car") | ||
+ | class Car { | ||
+ | public int numberOfDoors; | ||
+ | public int milesPerGallon; | ||
+ | } | ||
+ | </source> | ||
+ | org.example.SportsCar.java | ||
+ | <source lang="java"> | ||
+ | package org.example; | ||
+ | |||
+ | @XmlRootElement("sportscar-data") | ||
+ | @XmlDiscriminatorValue("sports-car") | ||
+ | class SportsCar { | ||
+ | public String quarterMileTime | ||
} | } | ||
</source> | </source> |
Revision as of 13:24, 17 August 2010
Phase 3 - MOXy Equavilents of JPA Annotations
This phase of development involves providing additional MOXy annotations and XML metadata support equivalent to that of JPA.
Annotations/XML Metadata
The following MOXy annotations/XML metadata will be targeted in this phase:
MOXy Annotation | XML Metadata Tag | Package | Type | Field | Method |
---|---|---|---|---|---|
XmlDiscriminatorNode | xml-discriminator-node | X | |||
XmlDiscriminatorValue | xml-discriminator-value | X |
Inheritance Support
XmlDiscriminatorNode
Purpose
Provide a means to set the class indicator field name when using inheritance.
Java Metadata
package org.eclipse.persistence.oxm.annotations; @Target({TYPE}) @Retention(RUNTIME) public @interface XmlDiscriminatorNode { String value(); }
XML Metadata
xml-discriminator-node
The xml-discriminator-node
metadata tag will be used to set the class indicator field name when using inheritance. The value will be in the form of an XPath to an attribute, i.e. @xsi:type
.
XmlDiscriminatorValue
Purpose
Provide a means to set a class indicator when using inheritance.
Java Metadata
package org.eclipse.persistence.oxm.annotations; @Target({TYPE}) @Retention(RUNTIME) public @interface XmlDiscriminatorValue { String value(); }
XML Metadata
xml-discriminator-value
The xml-discriminator-value
metadata tag will be used to set a class indicator when using inheritance.
XML Schema
Following is the proposed XSD change necessary to provide support for inheritance:
<xs:element name="java-type"> <xs:complexType> <xs:all> <xs:element ref="xml-type" minOccurs="0"/> <xs:element ref="xml-root-element" minOccurs="0"/> <xs:element ref="xml-see-also" minOccurs="0"/> <xs:element ref="xml-java-type-adapter" minOccurs="0"/> <xs:element ref="xml-class-extractor" minOccurs="0"/> <xs:element ref="xml-properties" minOccurs="0" /> <xs:element name="java-attributes" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element ref="java-attribute" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> </xs:all> <xs:attribute name="name" type="xs:string" /> <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" /> <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" /> <xs:attribute name="xml-customizer" type="xs:string" /> <xs:attribute name="xml-discriminator-node" type="xs:string" /> <xs:attribute name="xml-discriminator-value" type="xs:string" /> <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" /> <xs:attribute name="xml-transient" type="xs:boolean" default="false" /> </xs:complexType> </xs:element>
Example:
The following example will demonstrate how inheritance can be configured.
Using the xml-discriminator-node
and xml-discriminator-value
EclipseLink XML metadata tags to set the class indicator field name and class indicator(s) can be accomplished as follows:
<java-types> <java-type name="org.example.Vehicle" xml-discriminator-node="@vtype" xml-discriminator-value="vehicle"> <xml-root-element name="vehicle-data" /> </java-type> <java-type name="org.example.Car" xml-discriminator-value="car"> <xml-root-element name="car-data" /> </java-type> <java-type name="org.example.SportsCar" xml-discriminator-value="sports-car"> <xml-root-element name="sportscar-data" /> </java-type> </java-types>
Setting the class indicator field name and class indicator(s) via Annotations would be accomplished as follows: org.example.Vehicle.java
package org.example; @XmlRootElement("vehicle-data") @XmlDiscriminatorNode("@vtype") @XmlDiscriminatorValue("vehicle") class Vehicle { public String model; public String manufacturer; public int topSpeed; }
org.example.Car.java
package org.example; @XmlRootElement("car-data") @XmlDiscriminatorValue("car") class Car { public int numberOfDoors; public int milesPerGallon; }
org.example.SportsCar.java
package org.example; @XmlRootElement("sportscar-data") @XmlDiscriminatorValue("sports-car") class SportsCar { public String quarterMileTime }
Testing
This section identifies the test package(s) for each feature outlined on this page.
XML Metadata
XML Metadata | Package |
---|---|
|
Annotations
Annotation | Package |
---|---|
|
Open Issues
This section lists open issues.
Issue# | Description/Notes |
---|---|
1 |
Decisions
This section lists decisions made. These are intended to document the resolution of open issues or constraints added to the project that are important.
Decision# | Description/Notes | Decision |
---|---|---|
1 |