1 /*
   2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.xml.bind.annotation;
  27 
  28 import javax.activation.DataHandler;
  29 import static java.lang.annotation.ElementType.*;
  30 import java.lang.annotation.Retention;
  31 import static java.lang.annotation.RetentionPolicy.RUNTIME;
  32 import java.lang.annotation.Target;
  33 
  34 /**
  35  * Marks a field/property that its XML form is a uri reference to mime content.
  36  * The mime content is optimally stored out-of-line as an attachment.
  37  *
  38  * A field/property must always map to the {@link DataHandler} class.
  39  *
  40  * <h2>Usage</h2>
  41  * <pre>
  42  * &#64;{@link XmlRootElement}
  43  * class Foo {
  44  *   &#64;{@link XmlAttachmentRef}
  45  *   &#64;{@link XmlAttribute}
  46  *   {@link DataHandler} data;
  47  *
  48  *   &#64;{@link XmlAttachmentRef}
  49  *   &#64;{@link XmlElement}
  50  *   {@link DataHandler} body;
  51  * }
  52  * </pre>
  53  * The above code maps to the following XML:
  54  * <pre>
  55  * &lt;xs:element name="foo" xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd">
  56  *   &lt;xs:complexType>
  57  *     &lt;xs:sequence>
  58  *       &lt;xs:element name="body" type="ref:swaRef" minOccurs="0" />
  59  *     &lt;/xs:sequence>
  60  *     &lt;xs:attribute name="data" type="ref:swaRef" use="optional" />
  61  *   &lt;/xs:complexType>
  62  * &lt;/xs:element>
  63  * </pre>
  64  *
  65  * <p>
  66  * The above binding supports WS-I AP 1.0 <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html#Referencing_Attachments_from_the_SOAP_Envelope">WS-I Attachments Profile Version 1.0.</a>
  67  *
  68  * @author Kohsuke Kawaguchi
  69  * @since JAXB2.0
  70  */
  71 @Retention(RUNTIME)
  72 @Target({FIELD,METHOD,PARAMETER})
  73 public @interface XmlAttachmentRef {
  74 }