ohair@286: /* mkos@397: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. ohair@286: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@286: * ohair@286: * This code is free software; you can redistribute it and/or modify it ohair@286: * under the terms of the GNU General Public License version 2 only, as ohair@286: * published by the Free Software Foundation. Oracle designates this ohair@286: * particular file as subject to the "Classpath" exception as provided ohair@286: * by Oracle in the LICENSE file that accompanied this code. ohair@286: * ohair@286: * This code is distributed in the hope that it will be useful, but WITHOUT ohair@286: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@286: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@286: * version 2 for more details (a copy is included in the LICENSE file that ohair@286: * accompanied this code). ohair@286: * ohair@286: * You should have received a copy of the GNU General Public License version ohair@286: * 2 along with this work; if not, write to the Free Software Foundation, ohair@286: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@286: * ohair@286: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@286: * or visit www.oracle.com if you need additional information or have any ohair@286: * questions. ohair@286: */ ohair@286: ohair@286: package com.sun.xml.internal.ws.spi.db; ohair@286: ohair@286: import java.io.IOException; ohair@286: import java.util.Collection; ohair@286: import java.util.List; ohair@286: ohair@286: import javax.xml.bind.JAXBContext; ohair@286: import javax.xml.bind.JAXBException; ohair@286: import javax.xml.bind.Marshaller; ohair@286: import javax.xml.bind.SchemaOutputResolver; ohair@286: import javax.xml.bind.Unmarshaller; ohair@286: import javax.xml.bind.annotation.XmlAttachmentRef; ohair@286: import javax.xml.namespace.QName; ohair@286: ohair@286: import com.sun.istack.internal.NotNull; ohair@286: import com.sun.istack.internal.Nullable; ohair@286: ohair@286: /** ohair@286: * {@link JAXBContext} enhanced with JAXB RI specific functionalities. ohair@286: * ohair@286: *

ohair@286: * Subject to change without notice. ohair@286: * ohair@286: * @since 2.0 EA1 ohair@286: * @author ohair@286: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) ohair@286: * ohair@286: * @author shih-chang.chen@oracle.com ohair@286: */ ohair@286: public interface BindingContext { ohair@286: ohair@286: //following are found in JAXBContext used by jaxws ohair@286: abstract public Marshaller createMarshaller() throws JAXBException; ohair@286: abstract public Unmarshaller createUnmarshaller() throws JAXBException; ohair@286: abstract public JAXBContext getJAXBContext(); ohair@286: abstract public Object newWrapperInstace(Class wrapperType) ohair@286: throws InstantiationException, IllegalAccessException; ohair@286: ohair@286: ohair@286: ohair@286: ohair@286: ohair@286: /** ohair@286: * Returns true if this context includes a class ohair@286: * that has {@link XmlAttachmentRef}. ohair@286: * ohair@286: * @since 2.1 ohair@286: */ ohair@286: public abstract boolean hasSwaRef(); ohair@286: ohair@286: /** ohair@286: * If the given object is bound to an element in XML by JAXB, ohair@286: * returns the element name. ohair@286: * ohair@286: * @return null ohair@286: * if the object is not bound to an element. ohair@286: * @throws JAXBException ohair@286: * if the object is not known to this context. ohair@286: * ohair@286: * @since 2.0 EA1 ohair@286: */ ohair@286: public abstract @Nullable QName getElementName(@NotNull Object o) throws JAXBException; ohair@286: ohair@286: /** ohair@286: * Allows to retrieve the element name based on Class. ohair@286: * @param o ohair@286: * @return ohair@286: * @throws javax.xml.bind.JAXBException ohair@286: * @since 2.1.10 ohair@286: */ ohair@286: public abstract @Nullable QName getElementName(@NotNull Class o) throws JAXBException; ohair@286: ohair@286: /** ohair@286: * Creates a mini-marshaller/unmarshaller that can process a {@link TypeInfo}. ohair@286: * ohair@286: * @return alanb@368: * null if the specified reference is not given to {@link BindingContext#newWrapperInstace(Class)}. ohair@286: * ohair@286: * @since 2.0 EA1 ohair@286: */ ohair@286: public abstract XMLBridge createBridge(@NotNull TypeInfo ref); ohair@286: public abstract XMLBridge createFragmentBridge(); ohair@286: ohair@286: /** ohair@286: * Creates a new {@link BridgeContext} instance. ohair@286: * ohair@286: * @return ohair@286: * always a valid non-null instance. ohair@286: * ohair@286: * @since 2.0 EA1 ohair@286: */ ohair@286: // public abstract @NotNull BridgeContext createBridgeContext(); ohair@286: ohair@286: /** ohair@286: * Gets a {@link PropertyAccessor} for the specified element property of the specified wrapper bean class. ohair@286: * ohair@286: *

ohair@286: * This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.) ohair@286: * In the said mode, a wrapper bean is supposed to only have properties that match elements, ohair@286: * and for each element that appear in the content model there's one property. ohair@286: * ohair@286: *

ohair@286: * Therefore, this method takes a wrapper bean and a tag name that identifies a property ohair@286: * on the given wrapper bean, then returns a {@link PropertyAccessor} that allows the caller ohair@286: * to set/get a value from the property of the bean. ohair@286: * ohair@286: *

ohair@286: * This method is not designed for a performance. The caller is expected to cache the result. ohair@286: * ohair@286: * @param ohair@286: * type of the wrapper bean ohair@286: * @param ohair@286: * type of the property of the bean ohair@286: * @return ohair@286: * always return non-null valid accessor object. ohair@286: * @throws JAXBException ohair@286: * if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property ohair@286: * of the given name. ohair@286: * ohair@286: * @since 2.0 EA1 ohair@286: */ ohair@286: public abstract PropertyAccessor getElementPropertyAccessor( Class wrapperBean, String nsUri, String localName ) ohair@286: throws JAXBException; ohair@286: ohair@286: /** ohair@286: * Gets the namespace URIs statically known to this {@link JAXBContext}. ohair@286: * ohair@286: *

ohair@286: * When JAXB is used to marshal into sub-trees, it declares ohair@286: * these namespace URIs at each top-level element that it marshals. ohair@286: * ohair@286: * To avoid repeated namespace declarations at sub-elements, the application ohair@286: * may declare those namespaces at a higher level. ohair@286: * ohair@286: * @return ohair@286: * always non-null. ohair@286: * ohair@286: * @since 2.0 EA2 ohair@286: */ ohair@286: public abstract @NotNull List getKnownNamespaceURIs(); ohair@286: ohair@286: ohair@286: /** ohair@286: * Generates the schema documents from the model. ohair@286: * ohair@286: *

ohair@286: * The caller can use the additionalElementDecls parameter to ohair@286: * add element declarations to the generate schema. ohair@286: * For example, if the JAX-RPC passes in the following entry: ohair@286: * ohair@286: * {foo}bar -> DeclaredType for java.lang.String ohair@286: * ohair@286: * then JAXB generates the following element declaration (in the schema ohair@286: * document for the namespace "foo")" ohair@286: * ohair@286: * <xs:element name="bar" type="xs:string" /> ohair@286: * ohair@286: * This can be used for generating schema components necessary for WSDL. ohair@286: * ohair@286: * @param outputResolver ohair@286: * this object controls the output to which schemas ohair@286: * will be sent. ohair@286: * ohair@286: * @throws IOException ohair@286: * if {@link SchemaOutputResolver} throws an {@link IOException}. ohair@286: */ ohair@286: public abstract void generateSchema(@NotNull SchemaOutputResolver outputResolver) throws IOException; ohair@286: ohair@286: /** ohair@286: * Returns the name of the XML Type bound to the ohair@286: * specified Java type. ohair@286: * ohair@286: * @param tr ohair@286: * must not be null. This must be one of the {@link TypeInfo}s specified ohair@286: * in the {@link BindingContext#newInstance} method. ohair@286: * ohair@286: * @throws IllegalArgumentException ohair@286: * if the parameter is null or not a part of the {@link TypeInfo}s specified alanb@368: * in the {@link BindingContext#newWrapperInstace(Class)} method. ohair@286: * ohair@286: * @return null ohair@286: * if the referenced type is an anonymous and therefore doesn't have a name. ohair@286: */ ohair@286: public abstract QName getTypeName(@NotNull TypeInfo tr); ohair@286: ohair@286: /** ohair@286: * Gets the build information of the JAXB runtime. ohair@286: * ohair@286: * @return ohair@286: * may be null, if the runtime is loaded by a class loader that doesn't support ohair@286: * the access to the manifest informatino. ohair@286: */ ohair@286: public abstract @NotNull String getBuildId(); ohair@286: ohair@286: /** ohair@286: * The property that you can specify to {@link JAXBContext#newInstance} ohair@286: * to reassign the default namespace URI to something else at the runtime. ohair@286: * ohair@286: *

ohair@286: * The value of the property is {@link String}, and it is used as the namespace URI ohair@286: * that succeeds the default namespace URI. ohair@286: * ohair@286: * @since 2.0 EA1 ohair@286: */ ohair@286: public static final String DEFAULT_NAMESPACE_REMAP = "com.sun.xml.internal.bind.defaultNamespaceRemap"; ohair@286: ohair@286: /** ohair@286: * The property that you can specify to {@link JAXBContext#newInstance} ohair@286: * to put additional JAXB type references into the {@link JAXBContext}. ohair@286: * ohair@286: *

ohair@286: * The value of the property is {@link Collection}<{@link TypeInfo}>. ohair@286: * Those {@link TypeInfo}s can then be used to create {@link XMLBridge}s. ohair@286: * ohair@286: *

ohair@286: * This mechanism allows additional element declarations that were not a part of ohair@286: * the schema into the created {@link JAXBContext}. ohair@286: * ohair@286: * @since 2.0 EA1 ohair@286: */ ohair@286: public static final String TYPE_REFERENCES = "com.sun.xml.internal.bind.typeReferences"; ohair@286: ohair@286: /** ohair@286: * The property that you can specify to {@link JAXBContext#newInstance} ohair@286: * and {@link Marshaller#setProperty(String, Object)} ohair@286: * to enable the c14n marshalling support in the {@link JAXBContext}. ohair@286: * ohair@286: * @see C14nSupport_ArchitectureDocument ohair@286: * @since 2.0 EA2 ohair@286: */ ohair@286: public static final String CANONICALIZATION_SUPPORT = "com.sun.xml.internal.bind.c14n"; ohair@286: ohair@286: /** ohair@286: * The property that you can specify to {@link JAXBContext#newInstance} ohair@286: * to allow unmarshaller to honor xsi:nil anywhere, even if they are ohair@286: * not specifically allowed by the schema. ohair@286: * ohair@286: * @since 2.1.3 ohair@286: */ ohair@286: public static final String TREAT_EVERYTHING_NILLABLE = "com.sun.xml.internal.bind.treatEverythingNillable"; ohair@286: ohair@286: /** ohair@286: * The property that you can specify to {@link JAXBContext#newInstance} ohair@286: * to use alternative {@link RuntimeAnnotationReader} implementation. ohair@286: * ohair@286: * @since 2.1 EA2 ohair@286: */ ohair@286: // public static final String ANNOTATION_READER = RuntimeAnnotationReader.class.getName(); ohair@286: ohair@286: /** ohair@286: * Marshaller/Unmarshaller property to enable XOP processing. ohair@286: * ohair@286: * @since 2.0 EA2 ohair@286: */ ohair@286: public static final String ENABLE_XOP = "com.sun.xml.internal.bind.XOP"; ohair@286: ohair@286: /** ohair@286: * The property that you can specify to {@link JAXBContext#newInstance} ohair@286: * to specify specific classes that replace the reference to generic classes. ohair@286: * ohair@286: *

ohair@286: * See the release notes for more details about this feature. ohair@286: * ohair@286: * @since 2.1 EA2 ohair@286: */ ohair@286: public static final String SUBCLASS_REPLACEMENTS = "com.sun.xml.internal.bind.subclassReplacements"; ohair@286: ohair@286: /** ohair@286: * The property that you can specify to {@link JAXBContext#newInstance} ohair@286: * enable support of XmlAccessorFactory annotation in the {@link JAXBContext}. ohair@286: * ohair@286: * @since 2.1 EA2 ohair@286: */ ohair@286: public static final String XMLACCESSORFACTORY_SUPPORT = "com.sun.xml.internal.bind.XmlAccessorFactory"; ohair@286: ohair@286: /** ohair@286: * Retains references to PropertyInfos. ohair@286: * ohair@286: * @since 2.1.10 ohair@286: */ ohair@286: public static final String RETAIN_REFERENCE_TO_INFO = "retainReferenceToInfo"; ohair@286: ohair@286: }