Thu, 31 Aug 2017 15:18:52 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.xml.internal.ws.spi.db; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import java.io.IOException; |
aoqi@0 | 29 | import java.util.Collection; |
aoqi@0 | 30 | import java.util.List; |
aoqi@0 | 31 | |
aoqi@0 | 32 | import javax.xml.bind.JAXBContext; |
aoqi@0 | 33 | import javax.xml.bind.JAXBException; |
aoqi@0 | 34 | import javax.xml.bind.Marshaller; |
aoqi@0 | 35 | import javax.xml.bind.SchemaOutputResolver; |
aoqi@0 | 36 | import javax.xml.bind.Unmarshaller; |
aoqi@0 | 37 | import javax.xml.bind.annotation.XmlAttachmentRef; |
aoqi@0 | 38 | import javax.xml.namespace.QName; |
aoqi@0 | 39 | |
aoqi@0 | 40 | import com.sun.istack.internal.NotNull; |
aoqi@0 | 41 | import com.sun.istack.internal.Nullable; |
aoqi@0 | 42 | |
aoqi@0 | 43 | /** |
aoqi@0 | 44 | * {@link JAXBContext} enhanced with JAXB RI specific functionalities. |
aoqi@0 | 45 | * |
aoqi@0 | 46 | * <p> |
aoqi@0 | 47 | * <b>Subject to change without notice</b>. |
aoqi@0 | 48 | * |
aoqi@0 | 49 | * @since 2.0 EA1 |
aoqi@0 | 50 | * @author |
aoqi@0 | 51 | * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) |
aoqi@0 | 52 | * |
aoqi@0 | 53 | * @author shih-chang.chen@oracle.com |
aoqi@0 | 54 | */ |
aoqi@0 | 55 | public interface BindingContext { |
aoqi@0 | 56 | |
aoqi@0 | 57 | //following are found in JAXBContext used by jaxws |
aoqi@0 | 58 | abstract public Marshaller createMarshaller() throws JAXBException; |
aoqi@0 | 59 | abstract public Unmarshaller createUnmarshaller() throws JAXBException; |
aoqi@0 | 60 | abstract public JAXBContext getJAXBContext(); |
aoqi@0 | 61 | abstract public Object newWrapperInstace(Class<?> wrapperType) |
aoqi@0 | 62 | throws InstantiationException, IllegalAccessException; |
aoqi@0 | 63 | |
aoqi@0 | 64 | |
aoqi@0 | 65 | |
aoqi@0 | 66 | |
aoqi@0 | 67 | |
aoqi@0 | 68 | /** |
aoqi@0 | 69 | * Returns true if this context includes a class |
aoqi@0 | 70 | * that has {@link XmlAttachmentRef}. |
aoqi@0 | 71 | * |
aoqi@0 | 72 | * @since 2.1 |
aoqi@0 | 73 | */ |
aoqi@0 | 74 | public abstract boolean hasSwaRef(); |
aoqi@0 | 75 | |
aoqi@0 | 76 | /** |
aoqi@0 | 77 | * If the given object is bound to an element in XML by JAXB, |
aoqi@0 | 78 | * returns the element name. |
aoqi@0 | 79 | * |
aoqi@0 | 80 | * @return null |
aoqi@0 | 81 | * if the object is not bound to an element. |
aoqi@0 | 82 | * @throws JAXBException |
aoqi@0 | 83 | * if the object is not known to this context. |
aoqi@0 | 84 | * |
aoqi@0 | 85 | * @since 2.0 EA1 |
aoqi@0 | 86 | */ |
aoqi@0 | 87 | public abstract @Nullable QName getElementName(@NotNull Object o) throws JAXBException; |
aoqi@0 | 88 | |
aoqi@0 | 89 | /** |
aoqi@0 | 90 | * Allows to retrieve the element name based on Class. |
aoqi@0 | 91 | * @param o |
aoqi@0 | 92 | * @return |
aoqi@0 | 93 | * @throws javax.xml.bind.JAXBException |
aoqi@0 | 94 | * @since 2.1.10 |
aoqi@0 | 95 | */ |
aoqi@0 | 96 | public abstract @Nullable QName getElementName(@NotNull Class o) throws JAXBException; |
aoqi@0 | 97 | |
aoqi@0 | 98 | /** |
aoqi@0 | 99 | * Creates a mini-marshaller/unmarshaller that can process a {@link TypeInfo}. |
aoqi@0 | 100 | * |
aoqi@0 | 101 | * @return |
aoqi@0 | 102 | * null if the specified reference is not given to {@link BindingContext#newWrapperInstace(Class)}. |
aoqi@0 | 103 | * |
aoqi@0 | 104 | * @since 2.0 EA1 |
aoqi@0 | 105 | */ |
aoqi@0 | 106 | public abstract XMLBridge createBridge(@NotNull TypeInfo ref); |
aoqi@0 | 107 | public abstract XMLBridge createFragmentBridge(); |
aoqi@0 | 108 | |
aoqi@0 | 109 | /** |
aoqi@0 | 110 | * Creates a new {@link BridgeContext} instance. |
aoqi@0 | 111 | * |
aoqi@0 | 112 | * @return |
aoqi@0 | 113 | * always a valid non-null instance. |
aoqi@0 | 114 | * |
aoqi@0 | 115 | * @since 2.0 EA1 |
aoqi@0 | 116 | */ |
aoqi@0 | 117 | // public abstract @NotNull BridgeContext createBridgeContext(); |
aoqi@0 | 118 | |
aoqi@0 | 119 | /** |
aoqi@0 | 120 | * Gets a {@link PropertyAccessor} for the specified element property of the specified wrapper bean class. |
aoqi@0 | 121 | * |
aoqi@0 | 122 | * <p> |
aoqi@0 | 123 | * This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.) |
aoqi@0 | 124 | * In the said mode, a wrapper bean is supposed to only have properties that match elements, |
aoqi@0 | 125 | * and for each element that appear in the content model there's one property. |
aoqi@0 | 126 | * |
aoqi@0 | 127 | * <p> |
aoqi@0 | 128 | * Therefore, this method takes a wrapper bean and a tag name that identifies a property |
aoqi@0 | 129 | * on the given wrapper bean, then returns a {@link PropertyAccessor} that allows the caller |
aoqi@0 | 130 | * to set/get a value from the property of the bean. |
aoqi@0 | 131 | * |
aoqi@0 | 132 | * <p> |
aoqi@0 | 133 | * This method is not designed for a performance. The caller is expected to cache the result. |
aoqi@0 | 134 | * |
aoqi@0 | 135 | * @param <B> |
aoqi@0 | 136 | * type of the wrapper bean |
aoqi@0 | 137 | * @param <V> |
aoqi@0 | 138 | * type of the property of the bean |
aoqi@0 | 139 | * @return |
aoqi@0 | 140 | * always return non-null valid accessor object. |
aoqi@0 | 141 | * @throws JAXBException |
aoqi@0 | 142 | * if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property |
aoqi@0 | 143 | * of the given name. |
aoqi@0 | 144 | * |
aoqi@0 | 145 | * @since 2.0 EA1 |
aoqi@0 | 146 | */ |
aoqi@0 | 147 | public abstract <B,V> PropertyAccessor<B,V> getElementPropertyAccessor( Class<B> wrapperBean, String nsUri, String localName ) |
aoqi@0 | 148 | throws JAXBException; |
aoqi@0 | 149 | |
aoqi@0 | 150 | /** |
aoqi@0 | 151 | * Gets the namespace URIs statically known to this {@link JAXBContext}. |
aoqi@0 | 152 | * |
aoqi@0 | 153 | * <p> |
aoqi@0 | 154 | * When JAXB is used to marshal into sub-trees, it declares |
aoqi@0 | 155 | * these namespace URIs at each top-level element that it marshals. |
aoqi@0 | 156 | * |
aoqi@0 | 157 | * To avoid repeated namespace declarations at sub-elements, the application |
aoqi@0 | 158 | * may declare those namespaces at a higher level. |
aoqi@0 | 159 | * |
aoqi@0 | 160 | * @return |
aoqi@0 | 161 | * always non-null. |
aoqi@0 | 162 | * |
aoqi@0 | 163 | * @since 2.0 EA2 |
aoqi@0 | 164 | */ |
aoqi@0 | 165 | public abstract @NotNull List<String> getKnownNamespaceURIs(); |
aoqi@0 | 166 | |
aoqi@0 | 167 | |
aoqi@0 | 168 | /** |
aoqi@0 | 169 | * Generates the schema documents from the model. |
aoqi@0 | 170 | * |
aoqi@0 | 171 | * <p> |
aoqi@0 | 172 | * The caller can use the additionalElementDecls parameter to |
aoqi@0 | 173 | * add element declarations to the generate schema. |
aoqi@0 | 174 | * For example, if the JAX-RPC passes in the following entry: |
aoqi@0 | 175 | * |
aoqi@0 | 176 | * {foo}bar -> DeclaredType for java.lang.String |
aoqi@0 | 177 | * |
aoqi@0 | 178 | * then JAXB generates the following element declaration (in the schema |
aoqi@0 | 179 | * document for the namespace "foo")" |
aoqi@0 | 180 | * |
aoqi@0 | 181 | * <xs:element name="bar" type="xs:string" /> |
aoqi@0 | 182 | * |
aoqi@0 | 183 | * This can be used for generating schema components necessary for WSDL. |
aoqi@0 | 184 | * |
aoqi@0 | 185 | * @param outputResolver |
aoqi@0 | 186 | * this object controls the output to which schemas |
aoqi@0 | 187 | * will be sent. |
aoqi@0 | 188 | * |
aoqi@0 | 189 | * @throws IOException |
aoqi@0 | 190 | * if {@link SchemaOutputResolver} throws an {@link IOException}. |
aoqi@0 | 191 | */ |
aoqi@0 | 192 | public abstract void generateSchema(@NotNull SchemaOutputResolver outputResolver) throws IOException; |
aoqi@0 | 193 | |
aoqi@0 | 194 | /** |
aoqi@0 | 195 | * Returns the name of the XML Type bound to the |
aoqi@0 | 196 | * specified Java type. |
aoqi@0 | 197 | * |
aoqi@0 | 198 | * @param tr |
aoqi@0 | 199 | * must not be null. This must be one of the {@link TypeInfo}s specified |
aoqi@0 | 200 | * in the {@link BindingContext#newInstance} method. |
aoqi@0 | 201 | * |
aoqi@0 | 202 | * @throws IllegalArgumentException |
aoqi@0 | 203 | * if the parameter is null or not a part of the {@link TypeInfo}s specified |
aoqi@0 | 204 | * in the {@link BindingContext#newWrapperInstace(Class)} method. |
aoqi@0 | 205 | * |
aoqi@0 | 206 | * @return null |
aoqi@0 | 207 | * if the referenced type is an anonymous and therefore doesn't have a name. |
aoqi@0 | 208 | */ |
aoqi@0 | 209 | public abstract QName getTypeName(@NotNull TypeInfo tr); |
aoqi@0 | 210 | |
aoqi@0 | 211 | /** |
aoqi@0 | 212 | * Gets the build information of the JAXB runtime. |
aoqi@0 | 213 | * |
aoqi@0 | 214 | * @return |
aoqi@0 | 215 | * may be null, if the runtime is loaded by a class loader that doesn't support |
aoqi@0 | 216 | * the access to the manifest informatino. |
aoqi@0 | 217 | */ |
aoqi@0 | 218 | public abstract @NotNull String getBuildId(); |
aoqi@0 | 219 | |
aoqi@0 | 220 | /** |
aoqi@0 | 221 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 222 | * to reassign the default namespace URI to something else at the runtime. |
aoqi@0 | 223 | * |
aoqi@0 | 224 | * <p> |
aoqi@0 | 225 | * The value of the property is {@link String}, and it is used as the namespace URI |
aoqi@0 | 226 | * that succeeds the default namespace URI. |
aoqi@0 | 227 | * |
aoqi@0 | 228 | * @since 2.0 EA1 |
aoqi@0 | 229 | */ |
aoqi@0 | 230 | public static final String DEFAULT_NAMESPACE_REMAP = "com.sun.xml.internal.bind.defaultNamespaceRemap"; |
aoqi@0 | 231 | |
aoqi@0 | 232 | /** |
aoqi@0 | 233 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 234 | * to put additional JAXB type references into the {@link JAXBContext}. |
aoqi@0 | 235 | * |
aoqi@0 | 236 | * <p> |
aoqi@0 | 237 | * The value of the property is {@link Collection}<{@link TypeInfo}>. |
aoqi@0 | 238 | * Those {@link TypeInfo}s can then be used to create {@link XMLBridge}s. |
aoqi@0 | 239 | * |
aoqi@0 | 240 | * <p> |
aoqi@0 | 241 | * This mechanism allows additional element declarations that were not a part of |
aoqi@0 | 242 | * the schema into the created {@link JAXBContext}. |
aoqi@0 | 243 | * |
aoqi@0 | 244 | * @since 2.0 EA1 |
aoqi@0 | 245 | */ |
aoqi@0 | 246 | public static final String TYPE_REFERENCES = "com.sun.xml.internal.bind.typeReferences"; |
aoqi@0 | 247 | |
aoqi@0 | 248 | /** |
aoqi@0 | 249 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 250 | * and {@link Marshaller#setProperty(String, Object)} |
aoqi@0 | 251 | * to enable the c14n marshalling support in the {@link JAXBContext}. |
aoqi@0 | 252 | * |
aoqi@0 | 253 | * @see C14nSupport_ArchitectureDocument |
aoqi@0 | 254 | * @since 2.0 EA2 |
aoqi@0 | 255 | */ |
aoqi@0 | 256 | public static final String CANONICALIZATION_SUPPORT = "com.sun.xml.internal.bind.c14n"; |
aoqi@0 | 257 | |
aoqi@0 | 258 | /** |
aoqi@0 | 259 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 260 | * to allow unmarshaller to honor <tt>xsi:nil</tt> anywhere, even if they are |
aoqi@0 | 261 | * not specifically allowed by the schema. |
aoqi@0 | 262 | * |
aoqi@0 | 263 | * @since 2.1.3 |
aoqi@0 | 264 | */ |
aoqi@0 | 265 | public static final String TREAT_EVERYTHING_NILLABLE = "com.sun.xml.internal.bind.treatEverythingNillable"; |
aoqi@0 | 266 | |
aoqi@0 | 267 | /** |
aoqi@0 | 268 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 269 | * to use alternative {@link RuntimeAnnotationReader} implementation. |
aoqi@0 | 270 | * |
aoqi@0 | 271 | * @since 2.1 EA2 |
aoqi@0 | 272 | */ |
aoqi@0 | 273 | // public static final String ANNOTATION_READER = RuntimeAnnotationReader.class.getName(); |
aoqi@0 | 274 | |
aoqi@0 | 275 | /** |
aoqi@0 | 276 | * Marshaller/Unmarshaller property to enable XOP processing. |
aoqi@0 | 277 | * |
aoqi@0 | 278 | * @since 2.0 EA2 |
aoqi@0 | 279 | */ |
aoqi@0 | 280 | public static final String ENABLE_XOP = "com.sun.xml.internal.bind.XOP"; |
aoqi@0 | 281 | |
aoqi@0 | 282 | /** |
aoqi@0 | 283 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 284 | * to specify specific classes that replace the reference to generic classes. |
aoqi@0 | 285 | * |
aoqi@0 | 286 | * <p> |
aoqi@0 | 287 | * See the release notes for more details about this feature. |
aoqi@0 | 288 | * |
aoqi@0 | 289 | * @since 2.1 EA2 |
aoqi@0 | 290 | */ |
aoqi@0 | 291 | public static final String SUBCLASS_REPLACEMENTS = "com.sun.xml.internal.bind.subclassReplacements"; |
aoqi@0 | 292 | |
aoqi@0 | 293 | /** |
aoqi@0 | 294 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 295 | * enable support of XmlAccessorFactory annotation in the {@link JAXBContext}. |
aoqi@0 | 296 | * |
aoqi@0 | 297 | * @since 2.1 EA2 |
aoqi@0 | 298 | */ |
aoqi@0 | 299 | public static final String XMLACCESSORFACTORY_SUPPORT = "com.sun.xml.internal.bind.XmlAccessorFactory"; |
aoqi@0 | 300 | |
aoqi@0 | 301 | /** |
aoqi@0 | 302 | * Retains references to PropertyInfos. |
aoqi@0 | 303 | * |
aoqi@0 | 304 | * @since 2.1.10 |
aoqi@0 | 305 | */ |
aoqi@0 | 306 | public static final String RETAIN_REFERENCE_TO_INFO = "retainReferenceToInfo"; |
aoqi@0 | 307 | |
aoqi@0 | 308 | } |