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/293925/Phase10"
< EclipseLink | DesignDocs | 293925
Line 31: | Line 31: | ||
| align="center" | | | align="center" | | ||
|} | |} | ||
+ | |||
+ | == Example: XmlRegistry and XmlElementDecl Annotations == | ||
+ | |||
+ | === Java Metadata === | ||
+ | |||
+ | The following example will demonstrate how the [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlRegistry.html XmlRegistry] and [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlElementDecl.html XmlElementDecl] annotations can be applied: | ||
+ | |||
+ | ==== org.example.ObjectFactory.java ==== | ||
+ | |||
+ | <source lang="java"> | ||
+ | package org.example; | ||
+ | |||
+ | @javax.xml.bind.annotation.XmlRegistry | ||
+ | class ObjectFactory { | ||
+ | @javax.xml.bind.annotation.XmlElementDecl(name="foo") | ||
+ | javax.xml.bind.JAXBElement<String> createFoo(String s) { return "fooAsString"; } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | === XML Metadata === | ||
+ | |||
+ | ==== xml-registry ==== | ||
+ | |||
+ | If this is present in XML, the corresponding annotation will be ignored, and the true/false value set in XML used instead. | ||
+ | |||
+ | ==== xml-element-decl ==== | ||
+ | |||
+ | If this is present in XML, the corresponding annotation will be completely replaced. | ||
+ | |||
+ | ==== org/example/eclipselink-oxm.xml ==== | ||
+ | |||
+ | This XML file represents metadata overrides for the "org.example" package. | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <?xml version="1.0" encoding="US-ASCII"?> | ||
+ | <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"> | ||
+ | <xml-registries> | ||
+ | <xml-registry name="org.example.ObjectFactory"> | ||
+ | <xml-element-decl name="foo" /> | ||
+ | </xml-registry> | ||
+ | </xml-registries> | ||
+ | </xml-bindings> | ||
+ | </source> |
Revision as of 16:44, 18 January 2010
Phase 10 - XmlRegistry (page under construction)
Provide support for ObjectFactory methods.
Annotations
The following annotations will be targetted in this phase:
Annotation | XML Metadata Tag | Package | Type | Field | Method |
---|---|---|---|---|---|
XmlElementDecl | xml-element-decl | X | X | ||
XmlRegistry | xml-registry | X |
Example: XmlRegistry and XmlElementDecl Annotations
Java Metadata
The following example will demonstrate how the XmlRegistry and XmlElementDecl annotations can be applied:
org.example.ObjectFactory.java
package org.example; @javax.xml.bind.annotation.XmlRegistry class ObjectFactory { @javax.xml.bind.annotation.XmlElementDecl(name="foo") javax.xml.bind.JAXBElement<String> createFoo(String s) { return "fooAsString"; } }
XML Metadata
xml-registry
If this is present in XML, the corresponding annotation will be ignored, and the true/false value set in XML used instead.
xml-element-decl
If this is present in XML, the corresponding annotation will be completely replaced.
org/example/eclipselink-oxm.xml
This XML file represents metadata overrides for the "org.example" package.
<?xml version="1.0" encoding="US-ASCII"?> <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"> <xml-registries> <xml-registry name="org.example.ObjectFactory"> <xml-element-decl name="foo" /> </xml-registry> </xml-registries> </xml-bindings>