Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "EclipseLink/DesignDocs/277920/Phase2"

(Java Metadata)
(org.example.customer.Customer)
Line 37: Line 37:
 
</source>
 
</source>
  
=== org.example.customer.Customer ===
+
=== org.example.customer.Address ===
  
 
<source lang="java">
 
<source lang="java">
Line 45: Line 45:
 
@XmlAccessorType(XmlAccessType.FIELD)  
 
@XmlAccessorType(XmlAccessType.FIELD)  
 
@XmlType(
 
@XmlType(
     factoryClass=CustomerFactory.class,  
+
     factoryClass=Factory.class,  
     factoryMethod="createCustomer",  
+
     factoryMethod="createAddress",  
     name="customer-type",  
+
     name="address-type",  
 
     namespace="urn:customer",  
 
     namespace="urn:customer",  
     propOrder={})
+
     propOrder={"street", "city"})
public class Customer extends Person {
+
@XmlRootElement(name="address", namespace="urn:customer")
+
public class Address {
     private int customerId;
+
 
+
     private String street;
     public int getCustomerId() {
+
   
         return customerId;
+
    private String city;
 +
 
 +
     public String getStreet() {
 +
         return street;
 
     }
 
     }
+
 
     public void setCustomerId(int customerId) {
+
     public void setStreet(String street) {
         this.customerId = customerId;
+
         this.street = street;
 +
    }
 +
 
 +
    public String getCity() {
 +
        return city;
 +
    }
 +
 
 +
    public void setCity(String city) {
 +
        this.city = city;
 
     }
 
     }
+
   
 
}
 
}
 
</source>
 
</source>

Revision as of 10:08, 6 July 2009

Phase 2

Provide support for high level metadata.

Annotations

The following annotations will be targetted in this phase:

Annotation Package Type Field Method
XmlAccessorOrder X X    
XmlAccessorType X X    
XmlRootElement   X    
XmlType   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.

Back to the top