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

changeset 286
f50545b5e2f1
child 368
0989ad8c0860
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/db/BindingContext.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,338 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.xml.internal.ws.spi.db;
    1.30 +
    1.31 +import java.io.IOException;
    1.32 +import java.util.Collection;
    1.33 +import java.util.List;
    1.34 +
    1.35 +import javax.xml.bind.JAXBContext;
    1.36 +import javax.xml.bind.JAXBException;
    1.37 +import javax.xml.bind.Marshaller;
    1.38 +import javax.xml.bind.SchemaOutputResolver;
    1.39 +import javax.xml.bind.Unmarshaller;
    1.40 +import javax.xml.bind.annotation.XmlAttachmentRef;
    1.41 +import javax.xml.namespace.QName;
    1.42 +import javax.xml.transform.Result;
    1.43 +
    1.44 +import com.sun.istack.internal.NotNull;
    1.45 +import com.sun.istack.internal.Nullable;
    1.46 +//import com.sun.xml.internal.bind.api.BridgeContext;
    1.47 +//import com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader;
    1.48 +//import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet;
    1.49 +
    1.50 +/**
    1.51 + * {@link JAXBContext} enhanced with JAXB RI specific functionalities.
    1.52 + *
    1.53 + * <p>
    1.54 + * <b>Subject to change without notice</b>.
    1.55 + *
    1.56 + * @since 2.0 EA1
    1.57 + * @author
    1.58 + *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
    1.59 + *
    1.60 + * @author shih-chang.chen@oracle.com
    1.61 + */
    1.62 +public interface BindingContext {
    1.63 +
    1.64 +        //following are found in JAXBContext used by jaxws
    1.65 +        abstract public Marshaller createMarshaller() throws JAXBException;
    1.66 +        abstract public Unmarshaller createUnmarshaller() throws JAXBException;
    1.67 +        abstract public JAXBContext getJAXBContext();
    1.68 +    abstract public Object newWrapperInstace(Class<?> wrapperType)
    1.69 +            throws InstantiationException, IllegalAccessException;
    1.70 +
    1.71 +
    1.72 +
    1.73 +
    1.74 +
    1.75 +    /**
    1.76 +     * Returns true if this context includes a class
    1.77 +     * that has {@link XmlAttachmentRef}.
    1.78 +     *
    1.79 +     * @since 2.1
    1.80 +     */
    1.81 +    public abstract boolean hasSwaRef();
    1.82 +
    1.83 +    /**
    1.84 +     * If the given object is bound to an element in XML by JAXB,
    1.85 +     * returns the element name.
    1.86 +     *
    1.87 +     * @return null
    1.88 +     *      if the object is not bound to an element.
    1.89 +     * @throws JAXBException
    1.90 +     *      if the object is not known to this context.
    1.91 +     *
    1.92 +     * @since 2.0 EA1
    1.93 +     */
    1.94 +    public abstract @Nullable QName getElementName(@NotNull Object o) throws JAXBException;
    1.95 +
    1.96 +    /**
    1.97 +     * Allows to retrieve the element name based on Class.
    1.98 +     * @param o
    1.99 +     * @return
   1.100 +     * @throws javax.xml.bind.JAXBException
   1.101 +     * @since 2.1.10
   1.102 +     */
   1.103 +    public abstract @Nullable QName getElementName(@NotNull Class o) throws JAXBException;
   1.104 +
   1.105 +    /**
   1.106 +     * Creates a mini-marshaller/unmarshaller that can process a {@link TypeInfo}.
   1.107 +     *
   1.108 +     * @return
   1.109 +     *      null if the specified reference is not given to {@link BindingContext#newInstance}.
   1.110 +     *
   1.111 +     * @since 2.0 EA1
   1.112 +     */
   1.113 +    public abstract XMLBridge createBridge(@NotNull TypeInfo ref);
   1.114 +    public abstract XMLBridge createFragmentBridge();
   1.115 +
   1.116 +    /**
   1.117 +     * Creates a new {@link BridgeContext} instance.
   1.118 +     *
   1.119 +     * @return
   1.120 +     *      always a valid non-null instance.
   1.121 +     *
   1.122 +     * @since 2.0 EA1
   1.123 +     */
   1.124 +//    public abstract @NotNull BridgeContext createBridgeContext();
   1.125 +
   1.126 +    /**
   1.127 +     * Gets a {@link PropertyAccessor} for the specified element property of the specified wrapper bean class.
   1.128 +     *
   1.129 +     * <p>
   1.130 +     * This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.)
   1.131 +     * In the said mode, a wrapper bean is supposed to only have properties that match elements,
   1.132 +     * and for each element that appear in the content model there's one property.
   1.133 +     *
   1.134 +     * <p>
   1.135 +     * Therefore, this method takes a wrapper bean and a tag name that identifies a property
   1.136 +     * on the given wrapper bean, then returns a {@link PropertyAccessor} that allows the caller
   1.137 +     * to set/get a value from the property of the bean.
   1.138 +     *
   1.139 +     * <p>
   1.140 +     * This method is not designed for a performance. The caller is expected to cache the result.
   1.141 +     *
   1.142 +     * @param <B>
   1.143 +     *      type of the wrapper bean
   1.144 +     * @param <V>
   1.145 +     *      type of the property of the bean
   1.146 +     * @return
   1.147 +     *      always return non-null valid accessor object.
   1.148 +     * @throws JAXBException
   1.149 +     *      if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property
   1.150 +     *      of the given name.
   1.151 +     *
   1.152 +     * @since 2.0 EA1
   1.153 +     */
   1.154 +    public abstract <B,V> PropertyAccessor<B,V> getElementPropertyAccessor( Class<B> wrapperBean, String nsUri, String localName )
   1.155 +            throws JAXBException;
   1.156 +
   1.157 +    /**
   1.158 +     * Gets the namespace URIs statically known to this {@link JAXBContext}.
   1.159 +     *
   1.160 +     * <p>
   1.161 +     * When JAXB is used to marshal into sub-trees, it declares
   1.162 +     * these namespace URIs at each top-level element that it marshals.
   1.163 +     *
   1.164 +     * To avoid repeated namespace declarations at sub-elements, the application
   1.165 +     * may declare those namespaces at a higher level.
   1.166 +     *
   1.167 +     * @return
   1.168 +     *      always non-null.
   1.169 +     *
   1.170 +     * @since 2.0 EA2
   1.171 +     */
   1.172 +    public abstract @NotNull List<String> getKnownNamespaceURIs();
   1.173 +
   1.174 +
   1.175 +    /**
   1.176 +     * Generates the schema documents from the model.
   1.177 +     *
   1.178 +     * <p>
   1.179 +     * The caller can use the additionalElementDecls parameter to
   1.180 +     * add element declarations to the generate schema.
   1.181 +     * For example, if the JAX-RPC passes in the following entry:
   1.182 +     *
   1.183 +     * {foo}bar -> DeclaredType for java.lang.String
   1.184 +     *
   1.185 +     * then JAXB generates the following element declaration (in the schema
   1.186 +     * document for the namespace "foo")"
   1.187 +     *
   1.188 +     * &lt;xs:element name="bar" type="xs:string" />
   1.189 +     *
   1.190 +     * This can be used for generating schema components necessary for WSDL.
   1.191 +     *
   1.192 +     * @param outputResolver
   1.193 +     *      this object controls the output to which schemas
   1.194 +     *      will be sent.
   1.195 +     *
   1.196 +     * @throws IOException
   1.197 +     *      if {@link SchemaOutputResolver} throws an {@link IOException}.
   1.198 +     */
   1.199 +    public abstract void generateSchema(@NotNull SchemaOutputResolver outputResolver) throws IOException;
   1.200 +
   1.201 +    /**
   1.202 +     * Returns the name of the XML Type bound to the
   1.203 +     * specified Java type.
   1.204 +     *
   1.205 +     * @param tr
   1.206 +     *      must not be null. This must be one of the {@link TypeInfo}s specified
   1.207 +     *      in the {@link BindingContext#newInstance} method.
   1.208 +     *
   1.209 +     * @throws IllegalArgumentException
   1.210 +     *      if the parameter is null or not a part of the {@link TypeInfo}s specified
   1.211 +     *      in the {@link BindingContext#newInstance} method.
   1.212 +     *
   1.213 +     * @return null
   1.214 +     *      if the referenced type is an anonymous and therefore doesn't have a name.
   1.215 +     */
   1.216 +    public abstract QName getTypeName(@NotNull TypeInfo tr);
   1.217 +
   1.218 +    /**
   1.219 +     * Gets the build information of the JAXB runtime.
   1.220 +     *
   1.221 +     * @return
   1.222 +     *      may be null, if the runtime is loaded by a class loader that doesn't support
   1.223 +     *      the access to the manifest informatino.
   1.224 +     */
   1.225 +    public abstract @NotNull String getBuildId();
   1.226 +
   1.227 +    /**
   1.228 +     * Generates the episode file that represents the binding known to this {@link JAXBContext},
   1.229 +     * so that XJC can later do separate compilation.
   1.230 +     *
   1.231 +     * <p>
   1.232 +     * Episode file is really just a JAXB customization file, except that currently
   1.233 +     * we use the RI-specific SCD to refer to schema components.
   1.234 +     *
   1.235 +     * @param output
   1.236 +     *      This receives the generated episode file.
   1.237 +     *
   1.238 +     * @since 2.1
   1.239 +     */
   1.240 +//    public abstract void generateEpisode(Result output);
   1.241 +
   1.242 +    /**
   1.243 +     * Allows you to access the runtime model information of the JAXB XML/Java binding.
   1.244 +     *
   1.245 +     * <p>
   1.246 +     * This is useful for doing a deeper integration with the JAXB RI.
   1.247 +     * For more information about the model, see https://jaxb2-reflection.dev.java.net/
   1.248 +     *
   1.249 +     * @since 2.1.10
   1.250 +     */
   1.251 +//    public abstract RuntimeTypeInfoSet getRuntimeTypeInfoSet();
   1.252 +
   1.253 +    /**
   1.254 +     * The property that you can specify to {@link JAXBContext#newInstance}
   1.255 +     * to reassign the default namespace URI to something else at the runtime.
   1.256 +     *
   1.257 +     * <p>
   1.258 +     * The value of the property is {@link String}, and it is used as the namespace URI
   1.259 +     * that succeeds the default namespace URI.
   1.260 +     *
   1.261 +     * @since 2.0 EA1
   1.262 +     */
   1.263 +    public static final String DEFAULT_NAMESPACE_REMAP = "com.sun.xml.internal.bind.defaultNamespaceRemap";
   1.264 +
   1.265 +    /**
   1.266 +     * The property that you can specify to {@link JAXBContext#newInstance}
   1.267 +     * to put additional JAXB type references into the {@link JAXBContext}.
   1.268 +     *
   1.269 +     * <p>
   1.270 +     * The value of the property is {@link Collection}&lt;{@link TypeInfo}>.
   1.271 +     * Those {@link TypeInfo}s can then be used to create {@link XMLBridge}s.
   1.272 +     *
   1.273 +     * <p>
   1.274 +     * This mechanism allows additional element declarations that were not a part of
   1.275 +     * the schema into the created {@link JAXBContext}.
   1.276 +     *
   1.277 +     * @since 2.0 EA1
   1.278 +     */
   1.279 +    public static final String TYPE_REFERENCES = "com.sun.xml.internal.bind.typeReferences";
   1.280 +
   1.281 +    /**
   1.282 +     * The property that you can specify to {@link JAXBContext#newInstance}
   1.283 +     * and {@link Marshaller#setProperty(String, Object)}
   1.284 +     * to enable the c14n marshalling support in the {@link JAXBContext}.
   1.285 +     *
   1.286 +     * @see C14nSupport_ArchitectureDocument
   1.287 +     * @since 2.0 EA2
   1.288 +     */
   1.289 +    public static final String CANONICALIZATION_SUPPORT = "com.sun.xml.internal.bind.c14n";
   1.290 +
   1.291 +    /**
   1.292 +     * The property that you can specify to {@link JAXBContext#newInstance}
   1.293 +     * to allow unmarshaller to honor <tt>xsi:nil</tt> anywhere, even if they are
   1.294 +     * not specifically allowed by the schema.
   1.295 +     *
   1.296 +     * @since 2.1.3
   1.297 +     */
   1.298 +    public static final String TREAT_EVERYTHING_NILLABLE = "com.sun.xml.internal.bind.treatEverythingNillable";
   1.299 +
   1.300 +    /**
   1.301 +     * The property that you can specify to {@link JAXBContext#newInstance}
   1.302 +     * to use alternative {@link RuntimeAnnotationReader} implementation.
   1.303 +     *
   1.304 +     * @since 2.1 EA2
   1.305 +     */
   1.306 +//    public static final String ANNOTATION_READER = RuntimeAnnotationReader.class.getName();
   1.307 +
   1.308 +    /**
   1.309 +     * Marshaller/Unmarshaller property to enable XOP processing.
   1.310 +     *
   1.311 +     * @since 2.0 EA2
   1.312 +     */
   1.313 +    public static final String ENABLE_XOP = "com.sun.xml.internal.bind.XOP";
   1.314 +
   1.315 +    /**
   1.316 +     * The property that you can specify to {@link JAXBContext#newInstance}
   1.317 +     * to specify specific classes that replace the reference to generic classes.
   1.318 +     *
   1.319 +     * <p>
   1.320 +     * See the release notes for more details about this feature.
   1.321 +     *
   1.322 +     * @since 2.1 EA2
   1.323 +     */
   1.324 +    public static final String SUBCLASS_REPLACEMENTS = "com.sun.xml.internal.bind.subclassReplacements";
   1.325 +
   1.326 +    /**
   1.327 +     * The property that you can specify to {@link JAXBContext#newInstance}
   1.328 +     * enable support of XmlAccessorFactory annotation in the {@link JAXBContext}.
   1.329 +     *
   1.330 +     * @since 2.1 EA2
   1.331 +     */
   1.332 +    public static final String XMLACCESSORFACTORY_SUPPORT = "com.sun.xml.internal.bind.XmlAccessorFactory";
   1.333 +
   1.334 +    /**
   1.335 +     * Retains references to PropertyInfos.
   1.336 +     *
   1.337 +     * @since 2.1.10
   1.338 +     */
   1.339 +    public static final String RETAIN_REFERENCE_TO_INFO = "retainReferenceToInfo";
   1.340 +
   1.341 +}

mercurial