Fri, 23 Aug 2013 09:57:21 +0100
8022885: Update JAX-WS RI integration to 2.2.9-b14140
8013016: Rebase 8009009 against the latest jdk8/jaxws
Reviewed-by: alanb, chegar
ohair@286 | 1 | /* |
mkos@397 | 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. |
ohair@286 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@286 | 4 | * |
ohair@286 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohair@286 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@286 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohair@286 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@286 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohair@286 | 10 | * |
ohair@286 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@286 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@286 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@286 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohair@286 | 15 | * accompanied this code). |
ohair@286 | 16 | * |
ohair@286 | 17 | * You should have received a copy of the GNU General Public License version |
ohair@286 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohair@286 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@286 | 20 | * |
ohair@286 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@286 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@286 | 23 | * questions. |
ohair@286 | 24 | */ |
ohair@286 | 25 | |
ohair@286 | 26 | package javax.xml.bind.attachment; |
ohair@286 | 27 | |
ohair@286 | 28 | import javax.activation.DataHandler; |
ohair@286 | 29 | |
ohair@286 | 30 | /** |
ohair@286 | 31 | * <p>Enables JAXB unmarshalling of a root document containing optimized binary data formats.</p> |
ohair@286 | 32 | * |
ohair@286 | 33 | * <p>This API enables an efficient cooperative processing of optimized |
ohair@286 | 34 | * binary data formats between a JAXB 2.0 implementation and MIME-based package |
ohair@286 | 35 | * processor (MTOM/XOP and WS-I AP 1.0). JAXB unmarshals the body of a package, delegating the |
ohair@286 | 36 | * understanding of the packaging format being used to a MIME-based |
ohair@286 | 37 | * package processor that implements this abstract class.</p> |
ohair@286 | 38 | * |
ohair@286 | 39 | * <p>This abstract class identifies if a package requires XOP processing, {@link #isXOPPackage()} and provides retrieval of binary content stored as attachments by content-id.</p> |
ohair@286 | 40 | * |
ohair@286 | 41 | * <h2>Identifying the content-id, cid, to pass to <code>getAttachment*(String cid)</code></h2> |
ohair@286 | 42 | * <ul> |
ohair@286 | 43 | * <li> |
ohair@286 | 44 | * For XOP processing, the infoset representation of the cid is described |
ohair@286 | 45 | * in step 2a in |
ohair@286 | 46 | * <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#interpreting_xop_packages">Section 3.2 Interpreting XOP Packages</a> |
ohair@286 | 47 | * </li> |
ohair@286 | 48 | * <li> |
ohair@286 | 49 | * For WS-I AP 1.0, the cid is identified as an element or attribute of |
ohair@286 | 50 | * type <code>ref:swaRef </code> specified in |
ohair@286 | 51 | * <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html#Referencing_Attachments_from_the_SOAP_Envelope">Section 4.4 Referencing Attachments from the SOAP Envelope</a> |
ohair@286 | 52 | * </li> |
ohair@286 | 53 | * </ul> |
ohair@286 | 54 | * |
ohair@286 | 55 | * @author Marc Hadley |
ohair@286 | 56 | * @author Kohsuke Kawaguchi |
ohair@286 | 57 | * @author Joseph Fialli |
ohair@286 | 58 | * |
ohair@286 | 59 | * @since JAXB 2.0 |
ohair@286 | 60 | * |
ohair@286 | 61 | * @see javax.xml.bind.Unmarshaller#setAttachmentUnmarshaller(AttachmentUnmarshaller) |
ohair@286 | 62 | * |
ohair@286 | 63 | * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/">XML-binary Optimized Packaging</a> |
ohair@286 | 64 | * @see <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html">WS-I Attachments Profile Version 1.0.</a> |
ohair@286 | 65 | * @see <a href="http://www.w3.org/TR/xml-media-types/">Describing Media Content of Binary Data in XML</a> |
ohair@286 | 66 | */ |
ohair@286 | 67 | public abstract class AttachmentUnmarshaller { |
ohair@286 | 68 | /** |
ohair@286 | 69 | * <p>Lookup MIME content by content-id, <code>cid</code>, and return as a {@link DataHandler}.</p> |
ohair@286 | 70 | * |
ohair@286 | 71 | * <p>The returned <code>DataHandler</code> instance must be configured |
ohair@286 | 72 | * to meet the following required mapping constaint. |
ohair@286 | 73 | * <table border="2" rules="all" cellpadding="4"> |
ohair@286 | 74 | * <thead> |
ohair@286 | 75 | * <tr> |
ohair@286 | 76 | * <th align="center" colspan="2"> |
ohair@286 | 77 | * Required Mappings between MIME and Java Types |
ohair@286 | 78 | * </tr> |
ohair@286 | 79 | * <tr> |
ohair@286 | 80 | * <th>MIME Type</th> |
ohair@286 | 81 | * <th>Java Type</th> |
ohair@286 | 82 | * </tr> |
ohair@286 | 83 | * <tr> |
ohair@286 | 84 | * <th><code>DataHandler.getContentType()</code></th> |
ohair@286 | 85 | * <th><code>instanceof DataHandler.getContent()</code></th> |
ohair@286 | 86 | * </tr> |
ohair@286 | 87 | * </thead> |
ohair@286 | 88 | * <tbody> |
ohair@286 | 89 | * <tr> |
ohair@286 | 90 | * <td>image/gif</td> |
ohair@286 | 91 | * <td>java.awt.Image</td> |
ohair@286 | 92 | * </tr> |
ohair@286 | 93 | * <tr> |
ohair@286 | 94 | * <td>image/jpeg</td> |
ohair@286 | 95 | * <td>java.awt.Image</td> |
ohair@286 | 96 | * </tr> |
ohair@286 | 97 | * <tr> |
ohair@286 | 98 | * <td>text/xml or application/xml</td> |
ohair@286 | 99 | * <td>javax.xml.transform.Source</td> |
ohair@286 | 100 | * </tr> |
ohair@286 | 101 | * </tbody> |
ohair@286 | 102 | * </table> |
ohair@286 | 103 | * Note that it is allowable to support additional mappings.</p> |
ohair@286 | 104 | * |
ohair@286 | 105 | * @param cid It is expected to be a valid lexical form of the XML Schema |
ohair@286 | 106 | * <code>xs:anyURI</code> datatype. If <code>{@link #isXOPPackage()} |
ohair@286 | 107 | * ==true</code>, it must be a valid URI per the <code>cid:</code> URI scheme (see <a href="http://www.ietf.org/rfc/rfc2387.txt">RFC 2387</a>) |
ohair@286 | 108 | * |
ohair@286 | 109 | * @return |
ohair@286 | 110 | * a {@link DataHandler} that represents the MIME attachment. |
ohair@286 | 111 | * |
ohair@286 | 112 | * @throws IllegalArgumentException if the attachment for the given cid is not found. |
ohair@286 | 113 | */ |
ohair@286 | 114 | public abstract DataHandler getAttachmentAsDataHandler(String cid); |
ohair@286 | 115 | |
ohair@286 | 116 | /** |
ohair@286 | 117 | * <p>Retrieve the attachment identified by content-id, <code>cid</code>, as a <tt>byte[]</tt></p>. |
ohair@286 | 118 | * |
ohair@286 | 119 | * @param cid It is expected to be a valid lexical form of the XML Schema |
ohair@286 | 120 | * <code>xs:anyURI</code> datatype. If <code>{@link #isXOPPackage()} |
ohair@286 | 121 | * ==true</code>, it must be a valid URI per the <code>cid:</code> URI scheme (see <a href="http://www.ietf.org/rfc/rfc2387.txt">RFC 2387</a>) |
ohair@286 | 122 | * |
ohair@286 | 123 | * @return byte[] representation of attachment identified by cid. |
ohair@286 | 124 | * |
ohair@286 | 125 | * @throws IllegalArgumentException if the attachment for the given cid is not found. |
ohair@286 | 126 | */ |
ohair@286 | 127 | public abstract byte[] getAttachmentAsByteArray(String cid); |
ohair@286 | 128 | |
ohair@286 | 129 | /** |
ohair@286 | 130 | * <p>Read-only property that returns true if JAXB unmarshaller needs to perform XOP processing.</p> |
ohair@286 | 131 | * |
ohair@286 | 132 | * <p>This method returns <code>true</code> when the constraints specified |
ohair@286 | 133 | * in <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#identifying_xop_documents">Identifying XOP Documents</a> are met. |
ohair@286 | 134 | * This value must not change during the unmarshalling process.</p> |
ohair@286 | 135 | * |
ohair@286 | 136 | * @return true when MIME context is a XOP Document. |
ohair@286 | 137 | */ |
ohair@286 | 138 | public boolean isXOPPackage() { return false; } |
ohair@286 | 139 | } |