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/293925/Phase9"
(→Phase 9 - Attachments (Part 2)) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__</div> | <div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__</div> | ||
− | = Phase 9 - Attachments (part 2 | + | = Phase 9 - Attachments (part 2) = |
− | Provide support for WebService attachments. | + | Provide support for WebService attachments. Note that information pertaining to [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlAttachmentRef.html XmlAttachmentRef] and [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlMimeType.html XmlMimeType] support can be found [http://wiki.eclipse.org/EclipseLink/DesignDocs/277920/Phase5.1 here]. |
== Annotations == | == Annotations == | ||
Line 31: | Line 31: | ||
The following example will demonstrate how the [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlInlineBinaryData.html XmlInlineBinaryData] annotation can be applied at the class level: | The following example will demonstrate how the [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlInlineBinaryData.html XmlInlineBinaryData] annotation can be applied at the class level: | ||
− | ==== org.example. | + | ==== org.example.MyData.java ==== |
<source lang="java"> | <source lang="java"> | ||
Line 43: | Line 43: | ||
public byte[] bytes; | public byte[] bytes; | ||
public DataHandler getData() { return myDataHandler; } | public DataHandler getData() { return myDataHandler; } | ||
+ | public void setData(DataHandler data) { myDataHandler = data; } | ||
+ | } | ||
+ | </source> | ||
+ | === XML Metadata === | ||
+ | |||
+ | ==== xml-inline-binary-data ==== | ||
+ | |||
+ | If this is present in XML, the corresponding annotation will be ignored, and the true/false value set in XML used instead. Note that an @XmlInlineBinaryData annotated property will not be overridden by a class-level xml-inline-binary-data declaration in XML. | ||
+ | |||
+ | ==== 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"> | ||
+ | <java-types> | ||
+ | <java-type name="org.example.MyData" xml-inline-binary-data="true"> | ||
+ | <xml-root-element name="my-data"/> | ||
+ | </java-type> | ||
+ | </java-types> | ||
+ | </xml-bindings> | ||
+ | </source> | ||
+ | |||
+ | == Example: Property-level XmlInlineBinaryData Annotation == | ||
+ | |||
+ | === Java Metadata === | ||
+ | |||
+ | The following example will demonstrate how the [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlInlineBinaryData.html XmlInlineBinaryData] annotation can be applied at the property level: | ||
+ | |||
+ | ==== org.example.MyData.java ==== | ||
+ | |||
+ | <source lang="java"> | ||
+ | package org.example; | ||
+ | |||
+ | @javax.xml.bind.annotation.XmlRootElement(name="my-data") | ||
+ | public class MyData { | ||
+ | private DataHandler myDataHandler; | ||
+ | |||
+ | @javax.xml.bind.annotation.XmlInlineBinaryData | ||
+ | public byte[] bytes; | ||
+ | |||
+ | @javax.xml.bind.annotation.XmlInlineBinaryData | ||
+ | public DataHandler getData() { return myDataHandler; } | ||
public void setData(DataHandler data) { myDataHandler = data; } | public void setData(DataHandler data) { myDataHandler = data; } | ||
} | } | ||
Line 62: | Line 106: | ||
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"> | <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"> | ||
<java-types> | <java-types> | ||
− | <java-type name="org.example.MyData | + | <java-type name="org.example.MyData"> |
<xml-root-element name="my-data"/> | <xml-root-element name="my-data"/> | ||
+ | <java-attributes> | ||
+ | <xml-element java-attribute="bytes" xml-inline-binary-data="true" /> | ||
+ | <xml-element java-attribute="data" xml-inline-binary-data="true" /> | ||
+ | </java-attributes> | ||
</java-type> | </java-type> | ||
</java-types> | </java-types> | ||
</xml-bindings> | </xml-bindings> | ||
</source> | </source> |
Latest revision as of 07:44, 15 January 2010
Phase 9 - Attachments (part 2)
Provide support for WebService attachments. Note that information pertaining to XmlAttachmentRef and XmlMimeType support can be found here.
Annotations
The following annotations will be targetted in this phase:
Annotation | XML Metadata Tag | Package | Type | Field | Method |
---|---|---|---|---|---|
XmlInlineBinaryData | xml-inline-binary-data | X | X | X |
Example: Class-level XmlInlineBinaryData Annotation
Java Metadata
The following example will demonstrate how the XmlInlineBinaryData annotation can be applied at the class level:
org.example.MyData.java
package org.example; @javax.xml.bind.annotation.XmlInlineBinaryData @javax.xml.bind.annotation.XmlRootElement(name="my-data") public class MyData { private DataHandler myDataHandler; public byte[] bytes; public DataHandler getData() { return myDataHandler; } public void setData(DataHandler data) { myDataHandler = data; } }
XML Metadata
xml-inline-binary-data
If this is present in XML, the corresponding annotation will be ignored, and the true/false value set in XML used instead. Note that an @XmlInlineBinaryData annotated property will not be overridden by a class-level xml-inline-binary-data declaration in XML.
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"> <java-types> <java-type name="org.example.MyData" xml-inline-binary-data="true"> <xml-root-element name="my-data"/> </java-type> </java-types> </xml-bindings>
Example: Property-level XmlInlineBinaryData Annotation
Java Metadata
The following example will demonstrate how the XmlInlineBinaryData annotation can be applied at the property level:
org.example.MyData.java
package org.example; @javax.xml.bind.annotation.XmlRootElement(name="my-data") public class MyData { private DataHandler myDataHandler; @javax.xml.bind.annotation.XmlInlineBinaryData public byte[] bytes; @javax.xml.bind.annotation.XmlInlineBinaryData public DataHandler getData() { return myDataHandler; } public void setData(DataHandler data) { myDataHandler = data; } }
XML Metadata
xml-inline-binary-data
If this is present in XML, the corresponding annotation will be ignored, and the true/false value set in XML used instead.
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"> <java-types> <java-type name="org.example.MyData"> <xml-root-element name="my-data"/> <java-attributes> <xml-element java-attribute="bytes" xml-inline-binary-data="true" /> <xml-element java-attribute="data" xml-inline-binary-data="true" /> </java-attributes> </java-type> </java-types> </xml-bindings>