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/Phase1"
m (→xml-transient) |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | = Phase 1 = | + | <div style="border: 1px solid rgb(0, 0, 0); margin: 5px; padding: 5px; float: right;">__TOC__</div> |
+ | = Phase 1 - Bootstrapping = | ||
Provide support for boot strapping the JAXBContext. | Provide support for boot strapping the JAXBContext. | ||
− | == 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/XmlNs.html XmlNs] | + | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlNs.html XmlNs] |
+ | | xml-ns | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
|- | |- | ||
− | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlSchema.html XmlSchema] | + | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlSchema.html XmlSchema] |
+ | | xml-schema | ||
+ | | align="center" | X | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
|- | |- | ||
− | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlSeeAlso.html XmlSeeAlso] | + | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlSeeAlso.html XmlSeeAlso] |
+ | | xml-see-also | ||
+ | | align="center" | | ||
+ | | align="center" | X | ||
+ | | align="center" | | ||
+ | | align="center" | | ||
|- | |- | ||
− | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlTransient.html XmlTransient] || | + | | [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlTransient.html XmlTransient] |
+ | | xml-transient | ||
+ | | align="center" | | ||
+ | | align="center" | X | ||
+ | | align="center" | X | ||
+ | | align="center" | X | ||
|} | |} | ||
Line 108: | Line 134: | ||
== XML Metadata == | == XML Metadata == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Bootstrapping - Specifying Source of XML Overrides === | === Bootstrapping - Specifying Source of XML Overrides === | ||
− | The source of the XML override metadata | + | The source of the XML override metadata is to be passed to the JAXBContext at creation time. |
<source lang="java"> | <source lang="java"> |
Latest revision as of 12:10, 12 November 2009
Phase 1 - Bootstrapping
Provide support for boot strapping the JAXBContext.
Annotations
The following annotations will be targetted in this phase:
Annotation | XML Metadata Tag | Package | Type | Field | Method |
---|---|---|---|---|---|
XmlNs | xml-ns | ||||
XmlSchema | xml-schema | X | |||
XmlSeeAlso | xml-see-also | X | |||
XmlTransient | xml-transient | X | X | X |
Java Metadata
The following example will demonstrate how these annotations can be applied to Java classes:
org.example.customer.package-info.java
@XmlSchema( elementFormDefault=XmlNsForm.QUALIFIED, attributeFormDefault=XmlNsForm.UNQUALIFIED, namespace="urn:customer", xmlns={@XmlNs(prefix="ns1", namespaceURI="urn:customer")}) package org.example.customer; import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlSchema;
org.example.customer.Person
package org.example.customer; import javax.xml.bind.annotation.XmlTransient; @XmlTransient public abstract class Person { private int id; private String name; @XmlTransient public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
org.example.customer.Customer
package org.example.customer; import javax.xml.bind.annotation.XmlSeeAlso; import org.example.employee.Employee; @XmlSeeAlso({Employee.class}) public class Customer extends Person { private int customerId; public int getCustomerId() { return customerId; } public void setCustomerId(int customerId) { this.customerId = customerId; } }
org.example.employee.Employee
package org.example.employee; import org.example.customer.Person; public class Employee extends Person { }
XML Metadata
Bootstrapping - Specifying Source of XML Overrides
The source of the XML override metadata is to be passed to the JAXBContext at creation time.
Map<String, Source> xmlOverrides = new HashMap<String, Source>(); StreamSource customerOverrides = new StreamSource(new File("customer-override.xml")); xmlOverrides.put("org.example.customer", customerOverrides); Map<String, Object> properties = new HashMap<String, Object>(); properties.put("eclipselink-oxm-xml", xmlOverrides); JAXBContext jaxbContext = JAXBContext.newInstance("org.example.customer:org.example.employee", aClassLoader, properties);
xml-schema & xml-ns
If this is present in the XML then it completely replaces the corresponding annotation.
xml-transient
If this is present in the XML then it completely replaces the corresponding annotation. It can also be used to remove a transient annotation at the type level.
xml-see-also
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-schema element-form-default="QUALIFIED" attribute-form-default="UNQUALIFIED" namespace="urn:customer"> <xml-ns prefix="ns1" namespace-uri="urn:customer" /> </xml-schema> <java-types> <java-type name="Person" xml-transient="true"> <java-attributes> <xml-transient java-attribute="id"/> </java-attributes> </java-type> <java-type name="Customer"> <xml-see-also>org.example.employee.Employee</xml-see-also> </java-type> </java-types> </xml-bindings>