src/share/jaxws_classes/com/sun/xml/internal/ws/spi/db/BindingContext.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

ohair@286 1 /*
ohair@286 2 * Copyright (c) 1997, 2011, 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 com.sun.xml.internal.ws.spi.db;
ohair@286 27
ohair@286 28 import java.io.IOException;
ohair@286 29 import java.util.Collection;
ohair@286 30 import java.util.List;
ohair@286 31
ohair@286 32 import javax.xml.bind.JAXBContext;
ohair@286 33 import javax.xml.bind.JAXBException;
ohair@286 34 import javax.xml.bind.Marshaller;
ohair@286 35 import javax.xml.bind.SchemaOutputResolver;
ohair@286 36 import javax.xml.bind.Unmarshaller;
ohair@286 37 import javax.xml.bind.annotation.XmlAttachmentRef;
ohair@286 38 import javax.xml.namespace.QName;
ohair@286 39 import javax.xml.transform.Result;
ohair@286 40
ohair@286 41 import com.sun.istack.internal.NotNull;
ohair@286 42 import com.sun.istack.internal.Nullable;
ohair@286 43 //import com.sun.xml.internal.bind.api.BridgeContext;
ohair@286 44 //import com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader;
ohair@286 45 //import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet;
ohair@286 46
ohair@286 47 /**
ohair@286 48 * {@link JAXBContext} enhanced with JAXB RI specific functionalities.
ohair@286 49 *
ohair@286 50 * <p>
ohair@286 51 * <b>Subject to change without notice</b>.
ohair@286 52 *
ohair@286 53 * @since 2.0 EA1
ohair@286 54 * @author
ohair@286 55 * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
ohair@286 56 *
ohair@286 57 * @author shih-chang.chen@oracle.com
ohair@286 58 */
ohair@286 59 public interface BindingContext {
ohair@286 60
ohair@286 61 //following are found in JAXBContext used by jaxws
ohair@286 62 abstract public Marshaller createMarshaller() throws JAXBException;
ohair@286 63 abstract public Unmarshaller createUnmarshaller() throws JAXBException;
ohair@286 64 abstract public JAXBContext getJAXBContext();
ohair@286 65 abstract public Object newWrapperInstace(Class<?> wrapperType)
ohair@286 66 throws InstantiationException, IllegalAccessException;
ohair@286 67
ohair@286 68
ohair@286 69
ohair@286 70
ohair@286 71
ohair@286 72 /**
ohair@286 73 * Returns true if this context includes a class
ohair@286 74 * that has {@link XmlAttachmentRef}.
ohair@286 75 *
ohair@286 76 * @since 2.1
ohair@286 77 */
ohair@286 78 public abstract boolean hasSwaRef();
ohair@286 79
ohair@286 80 /**
ohair@286 81 * If the given object is bound to an element in XML by JAXB,
ohair@286 82 * returns the element name.
ohair@286 83 *
ohair@286 84 * @return null
ohair@286 85 * if the object is not bound to an element.
ohair@286 86 * @throws JAXBException
ohair@286 87 * if the object is not known to this context.
ohair@286 88 *
ohair@286 89 * @since 2.0 EA1
ohair@286 90 */
ohair@286 91 public abstract @Nullable QName getElementName(@NotNull Object o) throws JAXBException;
ohair@286 92
ohair@286 93 /**
ohair@286 94 * Allows to retrieve the element name based on Class.
ohair@286 95 * @param o
ohair@286 96 * @return
ohair@286 97 * @throws javax.xml.bind.JAXBException
ohair@286 98 * @since 2.1.10
ohair@286 99 */
ohair@286 100 public abstract @Nullable QName getElementName(@NotNull Class o) throws JAXBException;
ohair@286 101
ohair@286 102 /**
ohair@286 103 * Creates a mini-marshaller/unmarshaller that can process a {@link TypeInfo}.
ohair@286 104 *
ohair@286 105 * @return
ohair@286 106 * null if the specified reference is not given to {@link BindingContext#newInstance}.
ohair@286 107 *
ohair@286 108 * @since 2.0 EA1
ohair@286 109 */
ohair@286 110 public abstract XMLBridge createBridge(@NotNull TypeInfo ref);
ohair@286 111 public abstract XMLBridge createFragmentBridge();
ohair@286 112
ohair@286 113 /**
ohair@286 114 * Creates a new {@link BridgeContext} instance.
ohair@286 115 *
ohair@286 116 * @return
ohair@286 117 * always a valid non-null instance.
ohair@286 118 *
ohair@286 119 * @since 2.0 EA1
ohair@286 120 */
ohair@286 121 // public abstract @NotNull BridgeContext createBridgeContext();
ohair@286 122
ohair@286 123 /**
ohair@286 124 * Gets a {@link PropertyAccessor} for the specified element property of the specified wrapper bean class.
ohair@286 125 *
ohair@286 126 * <p>
ohair@286 127 * This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.)
ohair@286 128 * In the said mode, a wrapper bean is supposed to only have properties that match elements,
ohair@286 129 * and for each element that appear in the content model there's one property.
ohair@286 130 *
ohair@286 131 * <p>
ohair@286 132 * Therefore, this method takes a wrapper bean and a tag name that identifies a property
ohair@286 133 * on the given wrapper bean, then returns a {@link PropertyAccessor} that allows the caller
ohair@286 134 * to set/get a value from the property of the bean.
ohair@286 135 *
ohair@286 136 * <p>
ohair@286 137 * This method is not designed for a performance. The caller is expected to cache the result.
ohair@286 138 *
ohair@286 139 * @param <B>
ohair@286 140 * type of the wrapper bean
ohair@286 141 * @param <V>
ohair@286 142 * type of the property of the bean
ohair@286 143 * @return
ohair@286 144 * always return non-null valid accessor object.
ohair@286 145 * @throws JAXBException
ohair@286 146 * if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property
ohair@286 147 * of the given name.
ohair@286 148 *
ohair@286 149 * @since 2.0 EA1
ohair@286 150 */
ohair@286 151 public abstract <B,V> PropertyAccessor<B,V> getElementPropertyAccessor( Class<B> wrapperBean, String nsUri, String localName )
ohair@286 152 throws JAXBException;
ohair@286 153
ohair@286 154 /**
ohair@286 155 * Gets the namespace URIs statically known to this {@link JAXBContext}.
ohair@286 156 *
ohair@286 157 * <p>
ohair@286 158 * When JAXB is used to marshal into sub-trees, it declares
ohair@286 159 * these namespace URIs at each top-level element that it marshals.
ohair@286 160 *
ohair@286 161 * To avoid repeated namespace declarations at sub-elements, the application
ohair@286 162 * may declare those namespaces at a higher level.
ohair@286 163 *
ohair@286 164 * @return
ohair@286 165 * always non-null.
ohair@286 166 *
ohair@286 167 * @since 2.0 EA2
ohair@286 168 */
ohair@286 169 public abstract @NotNull List<String> getKnownNamespaceURIs();
ohair@286 170
ohair@286 171
ohair@286 172 /**
ohair@286 173 * Generates the schema documents from the model.
ohair@286 174 *
ohair@286 175 * <p>
ohair@286 176 * The caller can use the additionalElementDecls parameter to
ohair@286 177 * add element declarations to the generate schema.
ohair@286 178 * For example, if the JAX-RPC passes in the following entry:
ohair@286 179 *
ohair@286 180 * {foo}bar -> DeclaredType for java.lang.String
ohair@286 181 *
ohair@286 182 * then JAXB generates the following element declaration (in the schema
ohair@286 183 * document for the namespace "foo")"
ohair@286 184 *
ohair@286 185 * &lt;xs:element name="bar" type="xs:string" />
ohair@286 186 *
ohair@286 187 * This can be used for generating schema components necessary for WSDL.
ohair@286 188 *
ohair@286 189 * @param outputResolver
ohair@286 190 * this object controls the output to which schemas
ohair@286 191 * will be sent.
ohair@286 192 *
ohair@286 193 * @throws IOException
ohair@286 194 * if {@link SchemaOutputResolver} throws an {@link IOException}.
ohair@286 195 */
ohair@286 196 public abstract void generateSchema(@NotNull SchemaOutputResolver outputResolver) throws IOException;
ohair@286 197
ohair@286 198 /**
ohair@286 199 * Returns the name of the XML Type bound to the
ohair@286 200 * specified Java type.
ohair@286 201 *
ohair@286 202 * @param tr
ohair@286 203 * must not be null. This must be one of the {@link TypeInfo}s specified
ohair@286 204 * in the {@link BindingContext#newInstance} method.
ohair@286 205 *
ohair@286 206 * @throws IllegalArgumentException
ohair@286 207 * if the parameter is null or not a part of the {@link TypeInfo}s specified
ohair@286 208 * in the {@link BindingContext#newInstance} method.
ohair@286 209 *
ohair@286 210 * @return null
ohair@286 211 * if the referenced type is an anonymous and therefore doesn't have a name.
ohair@286 212 */
ohair@286 213 public abstract QName getTypeName(@NotNull TypeInfo tr);
ohair@286 214
ohair@286 215 /**
ohair@286 216 * Gets the build information of the JAXB runtime.
ohair@286 217 *
ohair@286 218 * @return
ohair@286 219 * may be null, if the runtime is loaded by a class loader that doesn't support
ohair@286 220 * the access to the manifest informatino.
ohair@286 221 */
ohair@286 222 public abstract @NotNull String getBuildId();
ohair@286 223
ohair@286 224 /**
ohair@286 225 * Generates the episode file that represents the binding known to this {@link JAXBContext},
ohair@286 226 * so that XJC can later do separate compilation.
ohair@286 227 *
ohair@286 228 * <p>
ohair@286 229 * Episode file is really just a JAXB customization file, except that currently
ohair@286 230 * we use the RI-specific SCD to refer to schema components.
ohair@286 231 *
ohair@286 232 * @param output
ohair@286 233 * This receives the generated episode file.
ohair@286 234 *
ohair@286 235 * @since 2.1
ohair@286 236 */
ohair@286 237 // public abstract void generateEpisode(Result output);
ohair@286 238
ohair@286 239 /**
ohair@286 240 * Allows you to access the runtime model information of the JAXB XML/Java binding.
ohair@286 241 *
ohair@286 242 * <p>
ohair@286 243 * This is useful for doing a deeper integration with the JAXB RI.
ohair@286 244 * For more information about the model, see https://jaxb2-reflection.dev.java.net/
ohair@286 245 *
ohair@286 246 * @since 2.1.10
ohair@286 247 */
ohair@286 248 // public abstract RuntimeTypeInfoSet getRuntimeTypeInfoSet();
ohair@286 249
ohair@286 250 /**
ohair@286 251 * The property that you can specify to {@link JAXBContext#newInstance}
ohair@286 252 * to reassign the default namespace URI to something else at the runtime.
ohair@286 253 *
ohair@286 254 * <p>
ohair@286 255 * The value of the property is {@link String}, and it is used as the namespace URI
ohair@286 256 * that succeeds the default namespace URI.
ohair@286 257 *
ohair@286 258 * @since 2.0 EA1
ohair@286 259 */
ohair@286 260 public static final String DEFAULT_NAMESPACE_REMAP = "com.sun.xml.internal.bind.defaultNamespaceRemap";
ohair@286 261
ohair@286 262 /**
ohair@286 263 * The property that you can specify to {@link JAXBContext#newInstance}
ohair@286 264 * to put additional JAXB type references into the {@link JAXBContext}.
ohair@286 265 *
ohair@286 266 * <p>
ohair@286 267 * The value of the property is {@link Collection}&lt;{@link TypeInfo}>.
ohair@286 268 * Those {@link TypeInfo}s can then be used to create {@link XMLBridge}s.
ohair@286 269 *
ohair@286 270 * <p>
ohair@286 271 * This mechanism allows additional element declarations that were not a part of
ohair@286 272 * the schema into the created {@link JAXBContext}.
ohair@286 273 *
ohair@286 274 * @since 2.0 EA1
ohair@286 275 */
ohair@286 276 public static final String TYPE_REFERENCES = "com.sun.xml.internal.bind.typeReferences";
ohair@286 277
ohair@286 278 /**
ohair@286 279 * The property that you can specify to {@link JAXBContext#newInstance}
ohair@286 280 * and {@link Marshaller#setProperty(String, Object)}
ohair@286 281 * to enable the c14n marshalling support in the {@link JAXBContext}.
ohair@286 282 *
ohair@286 283 * @see C14nSupport_ArchitectureDocument
ohair@286 284 * @since 2.0 EA2
ohair@286 285 */
ohair@286 286 public static final String CANONICALIZATION_SUPPORT = "com.sun.xml.internal.bind.c14n";
ohair@286 287
ohair@286 288 /**
ohair@286 289 * The property that you can specify to {@link JAXBContext#newInstance}
ohair@286 290 * to allow unmarshaller to honor <tt>xsi:nil</tt> anywhere, even if they are
ohair@286 291 * not specifically allowed by the schema.
ohair@286 292 *
ohair@286 293 * @since 2.1.3
ohair@286 294 */
ohair@286 295 public static final String TREAT_EVERYTHING_NILLABLE = "com.sun.xml.internal.bind.treatEverythingNillable";
ohair@286 296
ohair@286 297 /**
ohair@286 298 * The property that you can specify to {@link JAXBContext#newInstance}
ohair@286 299 * to use alternative {@link RuntimeAnnotationReader} implementation.
ohair@286 300 *
ohair@286 301 * @since 2.1 EA2
ohair@286 302 */
ohair@286 303 // public static final String ANNOTATION_READER = RuntimeAnnotationReader.class.getName();
ohair@286 304
ohair@286 305 /**
ohair@286 306 * Marshaller/Unmarshaller property to enable XOP processing.
ohair@286 307 *
ohair@286 308 * @since 2.0 EA2
ohair@286 309 */
ohair@286 310 public static final String ENABLE_XOP = "com.sun.xml.internal.bind.XOP";
ohair@286 311
ohair@286 312 /**
ohair@286 313 * The property that you can specify to {@link JAXBContext#newInstance}
ohair@286 314 * to specify specific classes that replace the reference to generic classes.
ohair@286 315 *
ohair@286 316 * <p>
ohair@286 317 * See the release notes for more details about this feature.
ohair@286 318 *
ohair@286 319 * @since 2.1 EA2
ohair@286 320 */
ohair@286 321 public static final String SUBCLASS_REPLACEMENTS = "com.sun.xml.internal.bind.subclassReplacements";
ohair@286 322
ohair@286 323 /**
ohair@286 324 * The property that you can specify to {@link JAXBContext#newInstance}
ohair@286 325 * enable support of XmlAccessorFactory annotation in the {@link JAXBContext}.
ohair@286 326 *
ohair@286 327 * @since 2.1 EA2
ohair@286 328 */
ohair@286 329 public static final String XMLACCESSORFACTORY_SUPPORT = "com.sun.xml.internal.bind.XmlAccessorFactory";
ohair@286 330
ohair@286 331 /**
ohair@286 332 * Retains references to PropertyInfos.
ohair@286 333 *
ohair@286 334 * @since 2.1.10
ohair@286 335 */
ohair@286 336 public static final String RETAIN_REFERENCE_TO_INFO = "retainReferenceToInfo";
ohair@286 337
ohair@286 338 }

mercurial