Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/DesignDocs/277920/Phase2"
(→Java Metadata) |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | = Phase 2 = | + | <div style="border: 1px solid rgb(0, 0, 0); margin: 5px; padding: 5px; float: right;">__TOC__</div> |
+ | = Phase 2 - High Level Metadata = | ||
Provide support for high level metadata. | Provide support for high level metadata. | ||
− | == Annotations == | + | == Annotations == |
− | The following annotations will be targetted in this phase: | + | The following annotations will be targetted in this phase: |
− | {| | + | {|{{BMTableStyle}} |
− | | | + | |-{{BMTHStyle}} |
− | ! Annotation | + | ! Annotation |
+ | ! XML Metadata Tag | ||
+ | ! Package | ||
+ | ! Type | ||
+ | ! Field | ||
+ | ! Method | ||
|- | |- | ||
− | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlAccessorOrder.html XmlAccessorOrder] || X | + | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlAccessorOrder.html XmlAccessorOrder] |
+ | | xml-accessor-order | ||
+ | | align="center" | X | ||
+ | | align="center" | X | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
|- | |- | ||
− | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlAccessorType.html XmlAccessorType] | + | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlAccessorType.html XmlAccessorType] |
+ | | xml-accessor-type | ||
+ | | align="center" | X | ||
+ | | align="center" | X | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
|- | |- | ||
− | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlRootElement.html XmlRootElement] | + | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlRootElement.html XmlRootElement] |
+ | | xml-root-element | ||
+ | | align="center" | | ||
+ | | align="center" | X | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
|- | |- | ||
− | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlType.html XmlType] | + | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlType.html XmlType] |
+ | | xml-type | ||
+ | | align="center" | | ||
+ | | align="center" | X | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
|} | |} | ||
Line 35: | Line 61: | ||
import javax.xml.bind.annotation.XmlAccessType; | import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | import javax.xml.bind.annotation.XmlAccessorType; | ||
+ | </source> | ||
+ | |||
+ | === org.example.customer.Address === | ||
+ | |||
+ | <source lang="java"> | ||
+ | package org.example.customer; | ||
+ | |||
+ | @XmlAccessorOrder(XmlAccessOrder.UNDEFINED) | ||
+ | @XmlAccessorType(XmlAccessType.FIELD) | ||
+ | @XmlType( | ||
+ | factoryClass=Factory.class, | ||
+ | factoryMethod="createAddress", | ||
+ | name="address-type", | ||
+ | namespace="urn:customer", | ||
+ | propOrder={"street", "city"}) | ||
+ | @XmlRootElement(name="address", namespace="urn:customer") | ||
+ | public class Address { | ||
+ | |||
+ | private String street; | ||
+ | private String city; | ||
+ | |||
+ | public String getStreet() { | ||
+ | return street; | ||
+ | } | ||
+ | |||
+ | public void setStreet(String street) { | ||
+ | this.street = street; | ||
+ | } | ||
+ | |||
+ | public String getCity() { | ||
+ | return city; | ||
+ | } | ||
+ | |||
+ | public void setCity(String city) { | ||
+ | this.city = city; | ||
+ | } | ||
+ | |||
+ | } | ||
</source> | </source> | ||
Line 54: | Line 118: | ||
If this is present in the XML then it completely replaces the corresponding annotation. | If this is present in the XML then it completely replaces the corresponding annotation. | ||
+ | |||
+ | === org/example/customer/eclipselink-oxm.xml === | ||
+ | |||
+ | This XML file represents metadata overrides for classes in the "org.example.customer" package. | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <xml-bindings | ||
+ | xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" | ||
+ | xml-accessor-order="ALPHABETICAL" | ||
+ | xml-accessor-type="PROPERTY"> | ||
+ | <java-types> | ||
+ | <java-type | ||
+ | name="Address" | ||
+ | xml-accessor-order="UNDEFINED" | ||
+ | xml-accessor-type="FIELD"> | ||
+ | <xml-type | ||
+ | factoryClass="Factory.class" | ||
+ | factoryMethod="createAddress" | ||
+ | name="address-type" | ||
+ | namespace="urn:customer" | ||
+ | propOrder="street city"/> | ||
+ | <xml-root-element | ||
+ | name="address" | ||
+ | namespace="urn:customer"/> | ||
+ | </java-type> | ||
+ | </java-types> | ||
+ | </xml-bindings> | ||
+ | </source> |
Latest revision as of 12:10, 12 November 2009
Contents
Phase 2 - High Level Metadata
Provide support for high level metadata.
Annotations
The following annotations will be targetted in this phase:
Annotation | XML Metadata Tag | Package | Type | Field | Method |
---|---|---|---|---|---|
XmlAccessorOrder | xml-accessor-order | X | X | ||
XmlAccessorType | xml-accessor-type | X | X | ||
XmlRootElement | xml-root-element | X | |||
XmlType | xml-type | X |
Java Metadata
The following example will demonstrate how these annotations can be applied to Java classes:
org.example.customer.package-info.java
@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL) @XmlAccessorType(XmlAccessType.PROPERTY) package org.example.customer; import javax.xml.bind.annotation.XmlAccessOrder; import javax.xml.bind.annotation.XmlAccessorOrder; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType;
org.example.customer.Address
package org.example.customer; @XmlAccessorOrder(XmlAccessOrder.UNDEFINED) @XmlAccessorType(XmlAccessType.FIELD) @XmlType( factoryClass=Factory.class, factoryMethod="createAddress", name="address-type", namespace="urn:customer", propOrder={"street", "city"}) @XmlRootElement(name="address", namespace="urn:customer") public class Address { private String street; private String city; public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } }
XML Metadata
xml-accessor-order
If this is present in the XML then it completely replaces the corresponding annotation.
xml-accessor-type
If this is present in the XML then it completely replaces the corresponding annotation.
xml-root-element
If this is present in the XML then it completely replaces the corresponding annotation.
xml-type
If this is present in the XML then it completely replaces the corresponding annotation.
org/example/customer/eclipselink-oxm.xml
This XML file represents metadata overrides for classes in the "org.example.customer" package.
<?xml version="1.0" encoding="UTF-8"?> <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" xml-accessor-order="ALPHABETICAL" xml-accessor-type="PROPERTY"> <java-types> <java-type name="Address" xml-accessor-order="UNDEFINED" xml-accessor-type="FIELD"> <xml-type factoryClass="Factory.class" factoryMethod="createAddress" name="address-type" namespace="urn:customer" propOrder="street city"/> <xml-root-element name="address" namespace="urn:customer"/> </java-type> </java-types> </xml-bindings>