Jump to: navigation, search

EclipseLink/DesignDocs/277920/Phase5.1

Phase 5.5 - Attachments (part 1)

Provide support for WebService attachments.

Annotations

The following annotations will be targetted in this phase:

Annotation XML Metadata Tag Package Type Field Method
XmlAttachmentRef xml-attachment-ref     X X
XmlMimeType xml-mime-type     X X


Example: XmlAttachmentRef annotation

Java Metadata

The following example will demonstrate how the XmlAttachmentRef annotation can be applied:

org.example.AttTypes.java

package org.example;
 
@javax.xml.bind.annotation.XmlRootElement(name="att-types")
public class AttTypes {
    @javax.xml.bind.annotation.XmlAttachmentRef
    @javax.xml.bind.annotation.XmlAttribute
    DataHandler data;
 
    @javax.xml.bind.annotation.XmlAttachmentRef
    @javax.xml.bind.annotation.XmlElement
    DataHandler body;
}

XML Metadata

xml-attachment-ref

If this is present in the XML then it completely replaces the corresponding annotation.

org/example/eclipselink-oxm.xml

This XML file represents metadata overrides for the "org.example.AttTypes" class.

<?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.AttTypes">
            <xml-root-element name="att-types"/>
            <java-attributes>
                <xml-attribute java-attribute="data" xml-attachment-ref="true" />
                <xml-element java-attribute="body" xml-attachment-ref="true" />
            </java-attributes>
        </java-type>
    </java-types>
</xml-bindings>

Example: XmlMimeType annotation

Java Metadata

The following example will demonstrate how the XmlMimeType annotation can be applied:

org.example.AttTypes.java

package org.example;
 
@javax.xml.bind.annotation.XmlRootElement(name="att-types")
public class AttTypes {
    @javax.xml.bind.annotation.XmlMimeType("text/plain")
    public byte[] b;
    @javax.xml.bind.annotation.XmlMimeType("application/binary")
    public DataHandler d;
    @javax.xml.bind.annotation.XmlMimeType("text/xml")
    public Source s;
    @javax.xml.bind.annotation.XmlMimeType("image/jpeg")
    public Image i;
}

XML Metadata

xml-mime-type

If this is present in the XML then it completely replaces the corresponding annotation.

org/example/eclipselink-oxm.xml

This XML file represents metadata overrides for the "org.example.AttTypes" class.

<?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.AttTypes">
            <java-attributes>
                <xml-element java-attribute="b" xml-mime-type="text/plain" />
                <xml-element java-attribute="d" xml-mime-type="application/binary" />
                <xml-element java-attribute="s" xml-mime-type="text/xml" />
                <xml-element java-attribute="i" xml-mime-type="image/jpeg" />
            </java-attributes>
        </java-type>
    </java-types>
</xml-bindings>