feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
308
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/BindingContext.java
Normal file
308
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/BindingContext.java
Normal file
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.SchemaOutputResolver;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlAttachmentRef;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
/**
|
||||
* {@link JAXBContext} enhanced with JAXB RI specific functionalities.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
* @author
|
||||
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface BindingContext {
|
||||
|
||||
//following are found in JAXBContext used by jaxws
|
||||
abstract public Marshaller createMarshaller() throws JAXBException;
|
||||
abstract public Unmarshaller createUnmarshaller() throws JAXBException;
|
||||
abstract public JAXBContext getJAXBContext();
|
||||
abstract public Object newWrapperInstace(Class<?> wrapperType)
|
||||
throws InstantiationException, IllegalAccessException;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this context includes a class
|
||||
* that has {@link XmlAttachmentRef}.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract boolean hasSwaRef();
|
||||
|
||||
/**
|
||||
* If the given object is bound to an element in XML by JAXB,
|
||||
* returns the element name.
|
||||
*
|
||||
* @return null
|
||||
* if the object is not bound to an element.
|
||||
* @throws JAXBException
|
||||
* if the object is not known to this context.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract @Nullable QName getElementName(@NotNull Object o) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Allows to retrieve the element name based on Class.
|
||||
* @param o
|
||||
* @return
|
||||
* @throws javax.xml.bind.JAXBException
|
||||
* @since 2.1.10
|
||||
*/
|
||||
public abstract @Nullable QName getElementName(@NotNull Class o) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Creates a mini-marshaller/unmarshaller that can process a {@link TypeInfo}.
|
||||
*
|
||||
* @return
|
||||
* null if the specified reference is not given to {@link BindingContext#newWrapperInstace(Class)}.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract XMLBridge createBridge(@NotNull TypeInfo ref);
|
||||
public abstract XMLBridge createFragmentBridge();
|
||||
|
||||
/**
|
||||
* Creates a new {@link BridgeContext} instance.
|
||||
*
|
||||
* @return
|
||||
* always a valid non-null instance.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
// public abstract @NotNull BridgeContext createBridgeContext();
|
||||
|
||||
/**
|
||||
* Gets a {@link PropertyAccessor} for the specified element property of the specified wrapper bean class.
|
||||
*
|
||||
* <p>
|
||||
* This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.)
|
||||
* In the said mode, a wrapper bean is supposed to only have properties that match elements,
|
||||
* and for each element that appear in the content model there's one property.
|
||||
*
|
||||
* <p>
|
||||
* Therefore, this method takes a wrapper bean and a tag name that identifies a property
|
||||
* on the given wrapper bean, then returns a {@link PropertyAccessor} that allows the caller
|
||||
* to set/get a value from the property of the bean.
|
||||
*
|
||||
* <p>
|
||||
* This method is not designed for a performance. The caller is expected to cache the result.
|
||||
*
|
||||
* @param <B>
|
||||
* type of the wrapper bean
|
||||
* @param <V>
|
||||
* type of the property of the bean
|
||||
* @return
|
||||
* always return non-null valid accessor object.
|
||||
* @throws JAXBException
|
||||
* if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property
|
||||
* of the given name.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract <B,V> PropertyAccessor<B,V> getElementPropertyAccessor( Class<B> wrapperBean, String nsUri, String localName )
|
||||
throws JAXBException;
|
||||
|
||||
/**
|
||||
* Gets the namespace URIs statically known to this {@link JAXBContext}.
|
||||
*
|
||||
* <p>
|
||||
* When JAXB is used to marshal into sub-trees, it declares
|
||||
* these namespace URIs at each top-level element that it marshals.
|
||||
*
|
||||
* To avoid repeated namespace declarations at sub-elements, the application
|
||||
* may declare those namespaces at a higher level.
|
||||
*
|
||||
* @return
|
||||
* always non-null.
|
||||
*
|
||||
* @since 2.0 EA2
|
||||
*/
|
||||
public abstract @NotNull List<String> getKnownNamespaceURIs();
|
||||
|
||||
|
||||
/**
|
||||
* Generates the schema documents from the model.
|
||||
*
|
||||
* <p>
|
||||
* The caller can use the additionalElementDecls parameter to
|
||||
* add element declarations to the generate schema.
|
||||
* For example, if the JAX-RPC passes in the following entry:
|
||||
*
|
||||
* {foo}bar -> DeclaredType for java.lang.String
|
||||
*
|
||||
* then JAXB generates the following element declaration (in the schema
|
||||
* document for the namespace "foo")"
|
||||
*
|
||||
* <xs:element name="bar" type="xs:string" />
|
||||
*
|
||||
* This can be used for generating schema components necessary for WSDL.
|
||||
*
|
||||
* @param outputResolver
|
||||
* this object controls the output to which schemas
|
||||
* will be sent.
|
||||
*
|
||||
* @throws IOException
|
||||
* if {@link SchemaOutputResolver} throws an {@link IOException}.
|
||||
*/
|
||||
public abstract void generateSchema(@NotNull SchemaOutputResolver outputResolver) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the name of the XML Type bound to the
|
||||
* specified Java type.
|
||||
*
|
||||
* @param tr
|
||||
* must not be null. This must be one of the {@link TypeInfo}s specified
|
||||
* in the {@link BindingContext#newInstance} method.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the parameter is null or not a part of the {@link TypeInfo}s specified
|
||||
* in the {@link BindingContext#newWrapperInstace(Class)} method.
|
||||
*
|
||||
* @return null
|
||||
* if the referenced type is an anonymous and therefore doesn't have a name.
|
||||
*/
|
||||
public abstract QName getTypeName(@NotNull TypeInfo tr);
|
||||
|
||||
/**
|
||||
* Gets the build information of the JAXB runtime.
|
||||
*
|
||||
* @return
|
||||
* may be null, if the runtime is loaded by a class loader that doesn't support
|
||||
* the access to the manifest informatino.
|
||||
*/
|
||||
public abstract @NotNull String getBuildId();
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to reassign the default namespace URI to something else at the runtime.
|
||||
*
|
||||
* <p>
|
||||
* The value of the property is {@link String}, and it is used as the namespace URI
|
||||
* that succeeds the default namespace URI.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public static final String DEFAULT_NAMESPACE_REMAP = "com.sun.xml.internal.bind.defaultNamespaceRemap";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to put additional JAXB type references into the {@link JAXBContext}.
|
||||
*
|
||||
* <p>
|
||||
* The value of the property is {@link Collection}<{@link TypeInfo}>.
|
||||
* Those {@link TypeInfo}s can then be used to create {@link XMLBridge}s.
|
||||
*
|
||||
* <p>
|
||||
* This mechanism allows additional element declarations that were not a part of
|
||||
* the schema into the created {@link JAXBContext}.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public static final String TYPE_REFERENCES = "com.sun.xml.internal.bind.typeReferences";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* and {@link Marshaller#setProperty(String, Object)}
|
||||
* to enable the c14n marshalling support in the {@link JAXBContext}.
|
||||
*
|
||||
* @see C14nSupport_ArchitectureDocument
|
||||
* @since 2.0 EA2
|
||||
*/
|
||||
public static final String CANONICALIZATION_SUPPORT = "com.sun.xml.internal.bind.c14n";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to allow unmarshaller to honor <tt>xsi:nil</tt> anywhere, even if they are
|
||||
* not specifically allowed by the schema.
|
||||
*
|
||||
* @since 2.1.3
|
||||
*/
|
||||
public static final String TREAT_EVERYTHING_NILLABLE = "com.sun.xml.internal.bind.treatEverythingNillable";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to use alternative {@link RuntimeAnnotationReader} implementation.
|
||||
*
|
||||
* @since 2.1 EA2
|
||||
*/
|
||||
// public static final String ANNOTATION_READER = RuntimeAnnotationReader.class.getName();
|
||||
|
||||
/**
|
||||
* Marshaller/Unmarshaller property to enable XOP processing.
|
||||
*
|
||||
* @since 2.0 EA2
|
||||
*/
|
||||
public static final String ENABLE_XOP = "com.sun.xml.internal.bind.XOP";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to specify specific classes that replace the reference to generic classes.
|
||||
*
|
||||
* <p>
|
||||
* See the release notes for more details about this feature.
|
||||
*
|
||||
* @since 2.1 EA2
|
||||
*/
|
||||
public static final String SUBCLASS_REPLACEMENTS = "com.sun.xml.internal.bind.subclassReplacements";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* enable support of XmlAccessorFactory annotation in the {@link JAXBContext}.
|
||||
*
|
||||
* @since 2.1 EA2
|
||||
*/
|
||||
public static final String XMLACCESSORFACTORY_SUPPORT = "com.sun.xml.internal.bind.XmlAccessorFactory";
|
||||
|
||||
/**
|
||||
* Retains references to PropertyInfos.
|
||||
*
|
||||
* @since 2.1.10
|
||||
*/
|
||||
public static final String RETAIN_REFERENCE_TO_INFO = "retainReferenceToInfo";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
|
||||
|
||||
import com.oracle.webservices.internal.api.databinding.DatabindingModeFeature;
|
||||
import com.sun.xml.internal.ws.db.glassfish.JAXBRIContextFactory;
|
||||
import com.sun.xml.internal.ws.util.ServiceConfigurationError;
|
||||
import com.sun.xml.internal.ws.util.ServiceFinder;
|
||||
|
||||
/**
|
||||
* BindingContextFactory
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
abstract public class BindingContextFactory {
|
||||
public static final String DefaultDatabindingMode = DatabindingModeFeature.GLASSFISH_JAXB;
|
||||
public static final String JAXB_CONTEXT_FACTORY_PROPERTY = BindingContextFactory.class.getName();
|
||||
public static final Logger LOGGER = Logger.getLogger(BindingContextFactory.class.getName());
|
||||
|
||||
// This iterator adds exception checking for proper logging.
|
||||
public static Iterator<BindingContextFactory> serviceIterator() {
|
||||
final ServiceFinder<BindingContextFactory> sf = ServiceFinder
|
||||
.find(BindingContextFactory.class);
|
||||
final Iterator<BindingContextFactory> ibcf = sf.iterator();
|
||||
|
||||
return new Iterator<BindingContextFactory>() {
|
||||
private BindingContextFactory bcf;
|
||||
|
||||
public boolean hasNext() {
|
||||
while (true) {
|
||||
try {
|
||||
if (ibcf.hasNext()) {
|
||||
bcf = ibcf.next();
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
} catch (ServiceConfigurationError e) {
|
||||
LOGGER.warning("skipping factory: ServiceConfigurationError: "
|
||||
+ e.getMessage());
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
LOGGER.fine("skipping factory: NoClassDefFoundError: "
|
||||
+ ncdfe.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BindingContextFactory next() {
|
||||
if (LOGGER.isLoggable(Level.FINER))
|
||||
LOGGER.finer("SPI found provider: " +
|
||||
bcf.getClass().getName());
|
||||
return bcf;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static private List<BindingContextFactory> factories() {
|
||||
List<BindingContextFactory> factories = new java.util.ArrayList<BindingContextFactory>();
|
||||
Iterator<BindingContextFactory> ibcf = serviceIterator();
|
||||
while (ibcf.hasNext())
|
||||
factories.add(ibcf.next());
|
||||
|
||||
// There should always be at least one factory available.
|
||||
if (factories.isEmpty()) {
|
||||
if (LOGGER.isLoggable(Level.FINER))
|
||||
LOGGER.log(Level.FINER, "No SPI providers for BindingContextFactory found, adding: "
|
||||
+ JAXBRIContextFactory.class.getName());
|
||||
factories.add(new JAXBRIContextFactory());
|
||||
}
|
||||
return factories;
|
||||
}
|
||||
|
||||
abstract protected BindingContext newContext(JAXBContext context);
|
||||
|
||||
abstract protected BindingContext newContext(BindingInfo bi);
|
||||
|
||||
/**
|
||||
* Check to see if the BindingContextFactory is for the databinding mode/flavor. The
|
||||
* String parameter can be the package name of the JAXBContext implementation as well.
|
||||
* @param databinding mode/flavor or the package name of the JAXBContext implementation.
|
||||
* @return
|
||||
*/
|
||||
abstract protected boolean isFor(String databinding);
|
||||
|
||||
/**
|
||||
* @deprecated - Does jaxws need this?
|
||||
*/
|
||||
abstract protected BindingContext getContext(Marshaller m);
|
||||
|
||||
static private BindingContextFactory getFactory(String mode) {
|
||||
for (BindingContextFactory f: factories()) {
|
||||
if (f.isFor(mode))
|
||||
return f;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static public BindingContext create(JAXBContext context) throws DatabindingException {
|
||||
return getJAXBFactory(context).newContext(context);
|
||||
}
|
||||
|
||||
static public BindingContext create(BindingInfo bi) {
|
||||
// Any mode configured in AbstractSEIModelImpl trumps all.
|
||||
// System property comes next, then SPI-located.
|
||||
String mode = bi.getDatabindingMode();
|
||||
if (mode != null) {
|
||||
if (LOGGER.isLoggable(Level.FINE))
|
||||
LOGGER.log(Level.FINE, "Using SEI-configured databindng mode: "
|
||||
+ mode);
|
||||
} else if ((mode = System.getProperty("BindingContextFactory")) != null) {
|
||||
// The following is left for backward compatibility and should
|
||||
// eventually be removed.
|
||||
bi.setDatabindingMode(mode);
|
||||
if (LOGGER.isLoggable(Level.FINE))
|
||||
LOGGER.log(Level.FINE, "Using databindng: " + mode
|
||||
+ " based on 'BindingContextFactory' System property");
|
||||
} else if ((mode = System.getProperty(JAXB_CONTEXT_FACTORY_PROPERTY)) != null) {
|
||||
bi.setDatabindingMode(mode);
|
||||
if (LOGGER.isLoggable(Level.FINE))
|
||||
LOGGER.log(Level.FINE, "Using databindng: " + mode
|
||||
+ " based on '" + JAXB_CONTEXT_FACTORY_PROPERTY
|
||||
+ "' System property");
|
||||
} else {
|
||||
// Find a default provider. Note we always ensure the list
|
||||
// is always non-empty.
|
||||
for (BindingContextFactory factory : factories()) {
|
||||
if (LOGGER.isLoggable(Level.FINE))
|
||||
LOGGER.log(Level.FINE,
|
||||
"Using SPI-determined databindng mode: "
|
||||
+ factory.getClass().getName());
|
||||
// Special case: no name lookup used.
|
||||
return factory.newContext(bi);
|
||||
}
|
||||
|
||||
// Should never get here as the list is non-empty.
|
||||
LOGGER.log(Level.SEVERE, "No Binding Context Factories found.");
|
||||
throw new DatabindingException("No Binding Context Factories found.");
|
||||
}
|
||||
BindingContextFactory f = getFactory(mode);
|
||||
if (f != null)
|
||||
return f.newContext(bi);
|
||||
LOGGER.severe("Unknown Databinding mode: " + mode);
|
||||
throw new DatabindingException("Unknown Databinding mode: " + mode);
|
||||
}
|
||||
|
||||
static public boolean isContextSupported(Object o) {
|
||||
if (o == null) return false;
|
||||
String pkgName = o.getClass().getPackage().getName();
|
||||
for (BindingContextFactory f: factories()) if (f.isFor(pkgName)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static BindingContextFactory getJAXBFactory(Object o) {
|
||||
String pkgName = o.getClass().getPackage().getName();
|
||||
BindingContextFactory f = getFactory(pkgName);
|
||||
if (f != null) return f;
|
||||
throw new DatabindingException("Unknown JAXBContext implementation: " + o.getClass());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - Does jaxws need this?
|
||||
*/
|
||||
static public BindingContext getBindingContext(Marshaller m) {
|
||||
return getJAXBFactory(m).getContext(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link BindingContext}.
|
||||
*
|
||||
* <p>
|
||||
* {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
|
||||
* return other JAXB providers that are not compatible with the JAX-RPC RI.
|
||||
* This method guarantees that the JAX-WS RI will finds the JAXB RI.
|
||||
*
|
||||
* @param classes
|
||||
* Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
|
||||
* @param typeRefs
|
||||
* See {@link #TYPE_REFERENCES} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @param subclassReplacements
|
||||
* See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @param defaultNamespaceRemap
|
||||
* See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
|
||||
* Can be null (and should be null for ordinary use of JAXB.)
|
||||
* @param c14nSupport
|
||||
* See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
|
||||
* @param ar
|
||||
* See {@link #ANNOTATION_READER} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @since JAXB 2.1 EA2
|
||||
*/
|
||||
// public static BindingContext newInstance(@NotNull Class[] classes,
|
||||
// @Nullable Collection<TypeInfo> typeRefs,
|
||||
// @Nullable Map<Class,Class> subclassReplacements,
|
||||
// @Nullable String defaultNamespaceRemap, boolean c14nSupport,
|
||||
// @Nullable RuntimeAnnotationReader ar) throws JAXBException {
|
||||
// return ContextFactory.createContext(classes, typeRefs, subclassReplacements,
|
||||
// defaultNamespaceRemap, c14nSupport, ar, false, false, false);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated
|
||||
// * Compatibility with older versions.
|
||||
// */
|
||||
// public static BindingContext newInstance(@NotNull Class[] classes,
|
||||
// @Nullable Collection<TypeInfo> typeRefs,
|
||||
// @Nullable String defaultNamespaceRemap, boolean c14nSupport ) throws JAXBException {
|
||||
// return newInstance(classes,typeRefs, Collections.<Class,Class>emptyMap(),
|
||||
// defaultNamespaceRemap,c14nSupport,null);
|
||||
// }
|
||||
}
|
||||
145
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/BindingHelper.java
Normal file
145
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/BindingHelper.java
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
//TODO SOAPVersion WebServiceFeatureList
|
||||
import com.sun.xml.internal.bind.util.Which;
|
||||
|
||||
//TODO Packet AbstractMessageImpl
|
||||
import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
|
||||
|
||||
//TODO DOMHeader DOMMessage SAAJMessage StatefulInstanceResolver
|
||||
import com.sun.xml.internal.bind.unmarshaller.DOMScanner;
|
||||
|
||||
//TODO MtomCodec
|
||||
import com.sun.xml.internal.bind.v2.runtime.output.Encoded;
|
||||
|
||||
//TODO ExceptionBean
|
||||
import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper;
|
||||
|
||||
//TODO AbstractWrapperBeanGenerator
|
||||
import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader;
|
||||
import com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader;
|
||||
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
|
||||
|
||||
//TODO WSDLGenerator
|
||||
import static com.sun.xml.internal.bind.v2.schemagen.Util.*;
|
||||
|
||||
import com.sun.xml.internal.bind.api.impl.NameConverter;
|
||||
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
/**
|
||||
* BindingHelper
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class BindingHelper {
|
||||
/**
|
||||
* Computes a Java identifier from a local name.
|
||||
*
|
||||
* <p>
|
||||
* This method faithfully implements the name mangling rule as specified in the JAXB spec.
|
||||
*
|
||||
* <p>
|
||||
* In JAXB, a collision with a Java reserved word (such as "return") never happens.
|
||||
* Accordingly, this method may return an identifier that collides with reserved words.
|
||||
*
|
||||
* <p>
|
||||
* Use <tt>JJavaName.isJavaIdentifier(String)</tt> to check for such collision.
|
||||
*
|
||||
* @return
|
||||
* Typically, this method returns "nameLikeThis".
|
||||
*/
|
||||
public static @NotNull String mangleNameToVariableName(@NotNull String localName) {
|
||||
return NameConverter.standard.toVariableName(localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a Java class name from a local name.
|
||||
*
|
||||
* <p>
|
||||
* This method faithfully implements the name mangling rule as specified in the JAXB spec.
|
||||
*
|
||||
* @return
|
||||
* Typically, this method returns "NameLikeThis".
|
||||
*/
|
||||
public static @NotNull String mangleNameToClassName(@NotNull String localName) {
|
||||
return NameConverter.standard.toClassName(localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a Java class name from a local name.
|
||||
*
|
||||
* <p>
|
||||
* This method faithfully implements the name mangling rule as specified in the JAXB spec.
|
||||
* This method works like {@link #mangleNameToClassName(String)} except that it looks
|
||||
* for "getClass" and returns something else.
|
||||
*
|
||||
* @return
|
||||
* Typically, this method returns "NameLikeThis".
|
||||
*/
|
||||
public static @NotNull String mangleNameToPropertyName(@NotNull String localName) {
|
||||
return NameConverter.standard.toPropertyName(localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameterization of the given base type.
|
||||
*
|
||||
* <p>
|
||||
* For example, given the following
|
||||
* <pre><xmp>
|
||||
* interface Foo<T> extends List<List<T>> {}
|
||||
* interface Bar extends Foo<String> {}
|
||||
* </xmp></pre>
|
||||
* This method works like this:
|
||||
* <pre><xmp>
|
||||
* getBaseClass( Bar, List ) = List<List<String>
|
||||
* getBaseClass( Bar, Foo ) = Foo<String>
|
||||
* getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>>
|
||||
* getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger>
|
||||
* </xmp></pre>
|
||||
*
|
||||
* @param type
|
||||
* The type that derives from {@code baseType}
|
||||
* @param baseType
|
||||
* The class whose parameterization we are interested in.
|
||||
* @return
|
||||
* The use of {@code baseType} in {@code type}.
|
||||
* or null if the type is not assignable to the base type.
|
||||
* @since 2.0 FCS
|
||||
*/
|
||||
public static @Nullable Type getBaseType(@NotNull Type type, @NotNull Class baseType) {
|
||||
return Utils.REFLECTION_NAVIGATOR.getBaseClass(type,baseType);
|
||||
}
|
||||
|
||||
public static <T> Class<T> erasure(Type t) {
|
||||
return (Class<T>) Utils.REFLECTION_NAVIGATOR.erasure(t);
|
||||
}
|
||||
}
|
||||
98
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/BindingInfo.java
Normal file
98
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/BindingInfo.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
|
||||
/**
|
||||
* BindingInfo
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class BindingInfo {
|
||||
|
||||
private String databindingMode;
|
||||
private String defaultNamespace;
|
||||
|
||||
private Collection<Class> contentClasses = new java.util.ArrayList<Class>();
|
||||
private Collection<TypeInfo> typeInfos = new java.util.ArrayList<TypeInfo>();
|
||||
private Map<Class,Class> subclassReplacements = new java.util.HashMap<Class, Class>();
|
||||
private Map<String, Object> properties = new java.util.HashMap<String, Object>();
|
||||
protected ClassLoader classLoader;
|
||||
|
||||
private SEIModel seiModel;
|
||||
private URL wsdlURL;
|
||||
|
||||
public String getDatabindingMode() {
|
||||
return databindingMode;
|
||||
}
|
||||
public void setDatabindingMode(String databindingMode) {
|
||||
this.databindingMode = databindingMode;
|
||||
}
|
||||
|
||||
public String getDefaultNamespace() {
|
||||
return defaultNamespace;
|
||||
}
|
||||
public void setDefaultNamespace(String defaultNamespace) {
|
||||
this.defaultNamespace = defaultNamespace;
|
||||
}
|
||||
|
||||
public Collection<Class> contentClasses() {
|
||||
return contentClasses;
|
||||
}
|
||||
public Collection<TypeInfo> typeInfos() {
|
||||
return typeInfos;
|
||||
}
|
||||
public Map<Class, Class> subclassReplacements() {
|
||||
return subclassReplacements;
|
||||
}
|
||||
public Map<String, Object> properties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public SEIModel getSEIModel() {
|
||||
return seiModel;
|
||||
}
|
||||
public void setSEIModel(SEIModel seiModel) {
|
||||
this.seiModel = seiModel;
|
||||
}
|
||||
public ClassLoader getClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
public URL getWsdlURL() {
|
||||
return wsdlURL;
|
||||
}
|
||||
public void setWsdlURL(URL wsdlURL) {
|
||||
this.wsdlURL = wsdlURL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
/**
|
||||
* Signals an error in Databinding.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class DatabindingException extends RuntimeException {
|
||||
public DatabindingException() {}
|
||||
public DatabindingException(String message) { super(message); }
|
||||
public DatabindingException(Throwable cause) { super(cause); }
|
||||
public DatabindingException(String message, Throwable cause) { super(message, cause); }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.oracle.webservices.internal.api.databinding.Databinding;
|
||||
import com.oracle.webservices.internal.api.databinding.WSDLGenerator;
|
||||
|
||||
import com.sun.xml.internal.ws.api.databinding.DatabindingConfig;
|
||||
|
||||
public interface DatabindingProvider {
|
||||
//We will need this for ServiceFinder
|
||||
boolean isFor(String databindingMode);
|
||||
void init(Map<String, Object> properties);
|
||||
Databinding create(DatabindingConfig config);
|
||||
WSDLGenerator wsdlGen(DatabindingConfig config);
|
||||
}
|
||||
96
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/FieldGetter.java
Normal file
96
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/FieldGetter.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
|
||||
/**
|
||||
* FieldGetter gets the value of a field from an instance.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
* @exclude
|
||||
*/
|
||||
public class FieldGetter extends PropertyGetterBase {
|
||||
|
||||
protected Field field;
|
||||
|
||||
public FieldGetter(Field f) {
|
||||
field = f;
|
||||
type = f.getType();
|
||||
}
|
||||
|
||||
public Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
static class PrivilegedGetter implements PrivilegedExceptionAction {
|
||||
private Object value;
|
||||
private Field field;
|
||||
private Object instance;
|
||||
public PrivilegedGetter(Field field, Object instance) {
|
||||
super();
|
||||
this.field = field;
|
||||
this.instance = instance;
|
||||
}
|
||||
public Object run() throws IllegalAccessException {
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
value = field.get(instance);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object get(final Object instance) {
|
||||
if (field.isAccessible()) {
|
||||
try {
|
||||
return field.get(instance);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
PrivilegedGetter privilegedGetter = new PrivilegedGetter(field, instance);
|
||||
try {
|
||||
AccessController.doPrivileged(privilegedGetter);
|
||||
} catch (PrivilegedActionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return privilegedGetter.value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public <A> A getAnnotation(Class<A> annotationType) {
|
||||
Class c = annotationType;
|
||||
return (A) field.getAnnotation(c);
|
||||
}
|
||||
}
|
||||
82
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/FieldSetter.java
Normal file
82
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/FieldSetter.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
|
||||
/**
|
||||
* FieldSetter
|
||||
* @author shih-chang.chen@oracle.com
|
||||
* @exclude
|
||||
*/
|
||||
public class FieldSetter extends PropertySetterBase {
|
||||
|
||||
protected Field field;
|
||||
|
||||
public FieldSetter(Field f) {
|
||||
field = f;
|
||||
type = f.getType();
|
||||
}
|
||||
|
||||
public Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void set(final Object instance, final Object resource) {
|
||||
if (field.isAccessible()) {
|
||||
try {
|
||||
field.set(instance, resource);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws IllegalAccessException {
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
field.set(instance, resource);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <A> A getAnnotation(Class<A> annotationType) {
|
||||
Class c = annotationType;
|
||||
return (A) field.getAnnotation(c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* JAXBWrapperAccessor
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public class JAXBWrapperAccessor extends WrapperAccessor {
|
||||
|
||||
protected Class<?> contentClass;
|
||||
protected HashMap<Object, Class> elementDeclaredTypes;
|
||||
|
||||
public JAXBWrapperAccessor(Class<?> wrapperBean) {
|
||||
contentClass = (Class<?>) wrapperBean;
|
||||
|
||||
HashMap<Object, PropertySetter> setByQName = new HashMap<Object, PropertySetter>();
|
||||
HashMap<Object, PropertySetter> setByLocalpart = new HashMap<Object, PropertySetter>();
|
||||
HashMap<String, Method> publicSetters = new HashMap<String, Method>();
|
||||
|
||||
HashMap<Object, PropertyGetter> getByQName = new HashMap<Object, PropertyGetter>();
|
||||
HashMap<Object, PropertyGetter> getByLocalpart = new HashMap<Object, PropertyGetter>();
|
||||
HashMap<String, Method> publicGetters = new HashMap<String, Method>();
|
||||
|
||||
HashMap<Object, Class> elementDeclaredTypesByQName = new HashMap<Object, Class>();
|
||||
HashMap<Object, Class> elementDeclaredTypesByLocalpart = new HashMap<Object, Class>();
|
||||
|
||||
for (Method method : contentClass.getMethods()) {
|
||||
if (PropertySetterBase.setterPattern(method)) {
|
||||
String key = method.getName()
|
||||
.substring(3, method.getName().length()).toLowerCase();
|
||||
publicSetters.put(key, method);
|
||||
}
|
||||
if (PropertyGetterBase.getterPattern(method)) {
|
||||
String methodName = method.getName();
|
||||
String key = methodName.startsWith("is") ? methodName
|
||||
.substring(2, method.getName().length()).toLowerCase()
|
||||
: methodName.substring(3, method.getName().length())
|
||||
.toLowerCase();
|
||||
publicGetters.put(key, method);
|
||||
}
|
||||
}
|
||||
HashSet<String> elementLocalNames = new HashSet<String>();
|
||||
for (Field field : getAllFields(contentClass)) {
|
||||
XmlElementWrapper xmlElemWrapper = field.getAnnotation(XmlElementWrapper.class);
|
||||
XmlElement xmlElem = field.getAnnotation(XmlElement.class);
|
||||
XmlElementRef xmlElemRef = field.getAnnotation(XmlElementRef.class);
|
||||
String fieldName = field.getName().toLowerCase();
|
||||
String namespace = "";
|
||||
String localName = field.getName();
|
||||
if (xmlElemWrapper != null) {
|
||||
namespace = xmlElemWrapper.namespace();
|
||||
if (xmlElemWrapper.name() != null && !xmlElemWrapper.name().equals("")
|
||||
&& !xmlElemWrapper.name().equals("##default")) {
|
||||
localName = xmlElemWrapper.name();
|
||||
}
|
||||
}else if (xmlElem != null) {
|
||||
namespace = xmlElem.namespace();
|
||||
if (xmlElem.name() != null && !xmlElem.name().equals("")
|
||||
&& !xmlElem.name().equals("##default")) {
|
||||
localName = xmlElem.name();
|
||||
}
|
||||
} else if (xmlElemRef != null) {
|
||||
namespace = xmlElemRef.namespace();
|
||||
if (xmlElemRef.name() != null && !xmlElemRef.name().equals("")
|
||||
&& !xmlElemRef.name().equals("##default")) {
|
||||
localName = xmlElemRef.name();
|
||||
}
|
||||
}
|
||||
if (elementLocalNames.contains(localName)) {
|
||||
this.elementLocalNameCollision = true;
|
||||
} else {
|
||||
elementLocalNames.add(localName);
|
||||
}
|
||||
|
||||
QName qname = new QName(namespace, localName);
|
||||
if (field.getType().equals(JAXBElement.class)) {
|
||||
if (field.getGenericType() instanceof ParameterizedType) {
|
||||
Type arg = ((ParameterizedType) field.getGenericType())
|
||||
.getActualTypeArguments()[0];
|
||||
if (arg instanceof Class) {
|
||||
elementDeclaredTypesByQName.put(qname, (Class) arg);
|
||||
elementDeclaredTypesByLocalpart.put(localName,
|
||||
(Class) arg);
|
||||
} else if (arg instanceof GenericArrayType) {
|
||||
Type componentType = ((GenericArrayType) arg)
|
||||
.getGenericComponentType();
|
||||
if (componentType instanceof Class) {
|
||||
Class arrayClass = Array.newInstance(
|
||||
(Class) componentType, 0).getClass();
|
||||
elementDeclaredTypesByQName.put(qname, arrayClass);
|
||||
elementDeclaredTypesByLocalpart.put(localName,
|
||||
arrayClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// _return
|
||||
if (fieldName.startsWith("_") && !localName.startsWith("_")) {
|
||||
fieldName = fieldName.substring(1);
|
||||
}
|
||||
Method setMethod = publicSetters.get(fieldName);
|
||||
Method getMethod = publicGetters.get(fieldName);
|
||||
PropertySetter setter = createPropertySetter(field, setMethod);
|
||||
PropertyGetter getter = createPropertyGetter(field, getMethod);
|
||||
setByQName.put(qname, setter);
|
||||
setByLocalpart.put(localName, setter);
|
||||
getByQName.put(qname, getter);
|
||||
getByLocalpart.put(localName, getter);
|
||||
}
|
||||
if (this.elementLocalNameCollision) {
|
||||
this.propertySetters = setByQName;
|
||||
this.propertyGetters = getByQName;
|
||||
elementDeclaredTypes = elementDeclaredTypesByQName;
|
||||
} else {
|
||||
this.propertySetters = setByLocalpart;
|
||||
this.propertyGetters = getByLocalpart;
|
||||
elementDeclaredTypes = elementDeclaredTypesByLocalpart;
|
||||
}
|
||||
}
|
||||
|
||||
static protected List<Field> getAllFields(Class<?> clz) {
|
||||
List<Field> list = new ArrayList<Field>();
|
||||
while (!Object.class.equals(clz)) {
|
||||
list.addAll(Arrays.asList(getDeclaredFields(clz)));
|
||||
clz = clz.getSuperclass();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static protected Field[] getDeclaredFields(final Class<?> clz) {
|
||||
try {
|
||||
return (System.getSecurityManager() == null) ? clz .getDeclaredFields() :
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Field[]>() {
|
||||
@Override
|
||||
public Field[] run() throws IllegalAccessException {
|
||||
return clz.getDeclaredFields();
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static protected PropertyGetter createPropertyGetter(Field field, Method getMethod) {
|
||||
if (!field.isAccessible()) {
|
||||
if (getMethod != null) {
|
||||
MethodGetter methodGetter = new MethodGetter(getMethod);
|
||||
if (methodGetter.getType().toString().equals(field.getType().toString())) {
|
||||
return methodGetter;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FieldGetter(field);
|
||||
}
|
||||
|
||||
static protected PropertySetter createPropertySetter(Field field,
|
||||
Method setter) {
|
||||
if (!field.isAccessible()) {
|
||||
if (setter != null) {
|
||||
MethodSetter injection = new MethodSetter(setter);
|
||||
if (injection.getType().toString().equals(field.getType().toString())) {
|
||||
return injection;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FieldSetter(field);
|
||||
}
|
||||
|
||||
private Class getElementDeclaredType(QName name) {
|
||||
Object key = (this.elementLocalNameCollision) ? name : name
|
||||
.getLocalPart();
|
||||
return elementDeclaredTypes.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyAccessor getPropertyAccessor(String ns, String name) {
|
||||
final QName n = new QName(ns, name);
|
||||
final PropertySetter setter = getPropertySetter(n);
|
||||
final PropertyGetter getter = getPropertyGetter(n);
|
||||
final boolean isJAXBElement = setter.getType()
|
||||
.equals(JAXBElement.class);
|
||||
final boolean isListType = java.util.List.class.isAssignableFrom(setter
|
||||
.getType());
|
||||
final Class elementDeclaredType = isJAXBElement ? getElementDeclaredType(n)
|
||||
: null;
|
||||
return new PropertyAccessor() {
|
||||
@Override
|
||||
public Object get(Object bean) throws DatabindingException {
|
||||
Object val;
|
||||
if (isJAXBElement) {
|
||||
JAXBElement<Object> jaxbElement = (JAXBElement<Object>) getter.get(bean);
|
||||
val = (jaxbElement == null) ? null : jaxbElement.getValue();
|
||||
} else {
|
||||
val = getter.get(bean);
|
||||
}
|
||||
if (val == null && isListType) {
|
||||
val = new java.util.ArrayList();
|
||||
set(bean, val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Object bean, Object value) throws DatabindingException {
|
||||
if (isJAXBElement) {
|
||||
JAXBElement<Object> jaxbElement = new JAXBElement<Object>(
|
||||
n, elementDeclaredType, contentClass, value);
|
||||
setter.set(bean, jaxbElement);
|
||||
} else {
|
||||
setter.set(bean, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/MethodGetter.java
Normal file
102
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/MethodGetter.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
|
||||
/**
|
||||
* MethodGetter
|
||||
* @author shih-chang.chen@oracle.com
|
||||
* @exclude
|
||||
*/
|
||||
public class MethodGetter extends PropertyGetterBase {
|
||||
|
||||
private Method method;
|
||||
|
||||
public MethodGetter(Method m) {
|
||||
method = m;
|
||||
type = m.getReturnType();
|
||||
}
|
||||
|
||||
public Method getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public <A> A getAnnotation(Class<A> annotationType) {
|
||||
Class c = annotationType;
|
||||
return (A) method.getAnnotation(c);
|
||||
}
|
||||
|
||||
|
||||
static class PrivilegedGetter implements PrivilegedExceptionAction {
|
||||
private Object value;
|
||||
private Method method;
|
||||
private Object instance;
|
||||
public PrivilegedGetter(Method m, Object instance) {
|
||||
super();
|
||||
this.method = m;
|
||||
this.instance = instance;
|
||||
}
|
||||
public Object run() throws IllegalAccessException {
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
try {
|
||||
value = method.invoke(instance, new Object[0]);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object get(final Object instance) {
|
||||
final Object[] args = new Object[0];
|
||||
try {
|
||||
if (method.isAccessible()) {
|
||||
return method.invoke(instance, args);
|
||||
} else {
|
||||
PrivilegedGetter privilegedGetter = new PrivilegedGetter(method, instance);
|
||||
try {
|
||||
AccessController.doPrivileged(privilegedGetter);
|
||||
} catch (PrivilegedActionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return privilegedGetter.value;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
87
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/MethodSetter.java
Normal file
87
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/MethodSetter.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
|
||||
/**
|
||||
* MethodInjection
|
||||
* @author shih-chang.chen@oracle.com
|
||||
* @exclude
|
||||
*/
|
||||
public class MethodSetter extends PropertySetterBase {
|
||||
|
||||
private Method method;
|
||||
|
||||
public MethodSetter(Method m) {
|
||||
method = m;
|
||||
type = m.getParameterTypes()[0];
|
||||
}
|
||||
|
||||
public Method getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public <A> A getAnnotation(Class<A> annotationType) {
|
||||
Class c = annotationType;
|
||||
return (A) method.getAnnotation(c);
|
||||
}
|
||||
|
||||
public void set(final Object instance, Object resource) {
|
||||
final Object[] args = {resource};
|
||||
if (method.isAccessible()) {
|
||||
try {
|
||||
method.invoke(instance, args);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws IllegalAccessException {
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
try {
|
||||
method.invoke(instance, args);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
322
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/OldBridge.java
Normal file
322
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/OldBridge.java
Normal file
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.attachment.AttachmentMarshaller;
|
||||
import javax.xml.bind.attachment.AttachmentUnmarshaller;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.api.BridgeContext;
|
||||
import com.sun.xml.internal.bind.v2.runtime.BridgeContextImpl;
|
||||
import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.ContentHandler;
|
||||
|
||||
/**
|
||||
* Mini-marshaller/unmarshaller that is specialized for a particular
|
||||
* element name and a type.
|
||||
*
|
||||
* <p>
|
||||
* Instances of this class is stateless and multi-thread safe.
|
||||
* They are reentrant.
|
||||
*
|
||||
* <p>
|
||||
* All the marshal operation generates fragments.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @since JAXB 2.0 EA1
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class OldBridge<T> {
|
||||
protected OldBridge(JAXBContextImpl context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
protected final JAXBContextImpl context;
|
||||
|
||||
/**
|
||||
* Gets the {@link BindingContext} to which this object belongs.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public @NotNull BindingContext getContext() {
|
||||
// return context;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while marshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final void marshal(T object,XMLStreamWriter output) throws JAXBException {
|
||||
marshal(object,output,null);
|
||||
}
|
||||
public final void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
m.setAttachmentMarshaller(am);
|
||||
marshal(m,object,output);
|
||||
m.setAttachmentMarshaller(null);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
|
||||
public final void marshal(@NotNull BridgeContext context,T object,XMLStreamWriter output) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, output );
|
||||
}
|
||||
|
||||
public abstract void marshal(@NotNull Marshaller m,T object,XMLStreamWriter output) throws JAXBException;
|
||||
|
||||
|
||||
/**
|
||||
* Marshals the specified type object with the implicit element name
|
||||
* associated with this instance of {@link XMLBridge}.
|
||||
*
|
||||
* @param nsContext
|
||||
* if this marshalling is done to marshal a subelement, this {@link NamespaceContext}
|
||||
* represents in-scope namespace bindings available for that element. Can be null,
|
||||
* in which case JAXB assumes no in-scope namespaces.
|
||||
* @throws JAXBException
|
||||
* if there was an error while marshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public void marshal(T object,OutputStream output, NamespaceContext nsContext) throws JAXBException {
|
||||
marshal(object,output,nsContext,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.2
|
||||
*/
|
||||
public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
m.setAttachmentMarshaller(am);
|
||||
marshal(m,object,output,nsContext);
|
||||
m.setAttachmentMarshaller(null);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
|
||||
public final void marshal(@NotNull BridgeContext context,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, output, nsContext );
|
||||
}
|
||||
|
||||
public abstract void marshal(@NotNull Marshaller m,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
|
||||
|
||||
|
||||
public final void marshal(T object,Node output) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
marshal(m,object,output);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
|
||||
public final void marshal(@NotNull BridgeContext context,T object,Node output) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, output );
|
||||
}
|
||||
|
||||
public abstract void marshal(@NotNull Marshaller m,T object,Node output) throws JAXBException;
|
||||
|
||||
|
||||
/**
|
||||
* @since 2.0 EA4
|
||||
*/
|
||||
public final void marshal(T object, ContentHandler contentHandler) throws JAXBException {
|
||||
marshal(object,contentHandler,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.2
|
||||
*/
|
||||
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
m.setAttachmentMarshaller(am);
|
||||
marshal(m,object,contentHandler);
|
||||
m.setAttachmentMarshaller(null);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
public final void marshal(@NotNull BridgeContext context,T object, ContentHandler contentHandler) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, contentHandler );
|
||||
}
|
||||
public abstract void marshal(@NotNull Marshaller m,T object, ContentHandler contentHandler) throws JAXBException;
|
||||
|
||||
/**
|
||||
* @since 2.0 EA4
|
||||
*/
|
||||
public final void marshal(T object, Result result) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
marshal(m,object,result);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
public final void marshal(@NotNull BridgeContext context,T object, Result result) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, result );
|
||||
}
|
||||
public abstract void marshal(@NotNull Marshaller m,T object, Result result) throws JAXBException;
|
||||
|
||||
|
||||
|
||||
private T exit(T r, Unmarshaller u) {
|
||||
u.setAttachmentUnmarshaller(null);
|
||||
context.unmarshallerPool.recycle(u);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link XMLBridge} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull XMLStreamReader in) throws JAXBException {
|
||||
return unmarshal(in,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull XMLStreamReader in, @Nullable AttachmentUnmarshaller au) throws JAXBException {
|
||||
Unmarshaller u = context.unmarshallerPool.take();
|
||||
u.setAttachmentUnmarshaller(au);
|
||||
return exit(unmarshal(u,in),u);
|
||||
}
|
||||
public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull XMLStreamReader in) throws JAXBException {
|
||||
return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
|
||||
}
|
||||
public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull XMLStreamReader in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link XMLBridge} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull Source in) throws JAXBException {
|
||||
return unmarshal(in,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull Source in, @Nullable AttachmentUnmarshaller au) throws JAXBException {
|
||||
Unmarshaller u = context.unmarshallerPool.take();
|
||||
u.setAttachmentUnmarshaller(au);
|
||||
return exit(unmarshal(u,in),u);
|
||||
}
|
||||
public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Source in) throws JAXBException {
|
||||
return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
|
||||
}
|
||||
public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull Source in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link XMLBridge} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull InputStream in) throws JAXBException {
|
||||
Unmarshaller u = context.unmarshallerPool.take();
|
||||
return exit(unmarshal(u,in),u);
|
||||
}
|
||||
public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull InputStream in) throws JAXBException {
|
||||
return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
|
||||
}
|
||||
public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull InputStream in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param n
|
||||
* Node to be unmarshalled.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 FCS
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull Node n) throws JAXBException {
|
||||
return unmarshal(n,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull Node n, @Nullable AttachmentUnmarshaller au) throws JAXBException {
|
||||
Unmarshaller u = context.unmarshallerPool.take();
|
||||
u.setAttachmentUnmarshaller(au);
|
||||
return exit(unmarshal(u,n),u);
|
||||
}
|
||||
public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Node n) throws JAXBException {
|
||||
return unmarshal( ((BridgeContextImpl)context).unmarshaller, n );
|
||||
}
|
||||
public abstract @NotNull T unmarshal(@NotNull Unmarshaller context, @NotNull Node n) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Gets the {@link TypeInfo} from which this bridge was created.
|
||||
*/
|
||||
public abstract TypeInfo getTypeReference();
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Accesses a particular property of a bean.
|
||||
*
|
||||
* <p>
|
||||
* This interface allows JAX-RPC to access an element property of a JAXB bean.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public interface PropertyAccessor<B,V> {
|
||||
|
||||
/**
|
||||
* Gets the value of the property of the given bean object.
|
||||
*
|
||||
* @param bean
|
||||
* must not be null.
|
||||
* @throws AccessorException
|
||||
* if failed to set a value. For example, the getter method
|
||||
* may throw an exception.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract V get(B bean) throws DatabindingException;
|
||||
|
||||
/**
|
||||
* Sets the value of the property of the given bean object.
|
||||
*
|
||||
* @param bean
|
||||
* must not be null.
|
||||
* @param value
|
||||
* the value to be set. Setting value to null means resetting
|
||||
* to the VM default value (even for primitive properties.)
|
||||
* @throws AccessorException
|
||||
* if failed to set a value. For example, the setter method
|
||||
* may throw an exception.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract void set(B bean,V value) throws DatabindingException;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
/**
|
||||
* PropertyGetter
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
* @exclude
|
||||
*/
|
||||
public interface PropertyGetter {
|
||||
|
||||
public Class getType();
|
||||
|
||||
public <A> A getAnnotation(Class<A> annotationType);
|
||||
|
||||
public Object get(Object instance);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
/**
|
||||
* This is the Gtter of a bean property.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
* @exclude
|
||||
*/
|
||||
public abstract class PropertyGetterBase implements PropertyGetter {
|
||||
protected Class type;
|
||||
|
||||
public Class getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
static public boolean getterPattern(java.lang.reflect.Method method) {
|
||||
if (!method.getReturnType().equals(void.class) &&
|
||||
(method.getParameterTypes() == null ||
|
||||
method.getParameterTypes().length == 0)) {
|
||||
if (method.getName().startsWith("get") &&
|
||||
method.getName().length() > 3) {
|
||||
return true;
|
||||
} else {
|
||||
if (method.getReturnType().equals(boolean.class) &&
|
||||
method.getName().startsWith("is") &&
|
||||
method.getName().length() > 2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
/**
|
||||
* PropertySetter
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
* @exclude
|
||||
*/
|
||||
public interface PropertySetter {
|
||||
|
||||
public Class getType();
|
||||
|
||||
public <A> A getAnnotation(Class<A> annotationType);
|
||||
|
||||
public void set(Object instance, Object resource);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
/**
|
||||
* This is the Setter of a bean property.
|
||||
* @author shih-chang.chen@oracle.com
|
||||
* @exclude
|
||||
*/
|
||||
public abstract class PropertySetterBase implements PropertySetter {
|
||||
protected Class type;
|
||||
|
||||
public Class getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
static public boolean setterPattern(java.lang.reflect.Method method) {
|
||||
return (method.getName().startsWith("set") &&
|
||||
method.getName().length() > 3 &&
|
||||
method.getReturnType().equals(void.class) &&
|
||||
method.getParameterTypes() != null &&
|
||||
method.getParameterTypes().length == 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.attachment.AttachmentMarshaller;
|
||||
import javax.xml.bind.attachment.AttachmentUnmarshaller;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.ContentHandler;
|
||||
|
||||
/**
|
||||
* RepeatedElementBridge
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public class RepeatedElementBridge<T> implements XMLBridge<T> {
|
||||
|
||||
XMLBridge<T> delegate;
|
||||
CollectionHandler collectionHandler;
|
||||
|
||||
public RepeatedElementBridge(TypeInfo typeInfo, XMLBridge xb) {
|
||||
delegate = xb;
|
||||
collectionHandler = create(typeInfo);
|
||||
}
|
||||
|
||||
public CollectionHandler collectionHandler() {
|
||||
return collectionHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingContext context() {
|
||||
return delegate.context();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(T object, XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
|
||||
delegate.marshal(object, output, am);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(T object, OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
|
||||
delegate.marshal(object, output, nsContext, am);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(T object, Node output) throws JAXBException {
|
||||
delegate.marshal(object, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
|
||||
delegate.marshal(object, contentHandler, am);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(T object, Result result) throws JAXBException {
|
||||
delegate.marshal(object, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T unmarshal(XMLStreamReader in, AttachmentUnmarshaller au) throws JAXBException {
|
||||
return delegate.unmarshal(in, au);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T unmarshal(Source in, AttachmentUnmarshaller au) throws JAXBException {
|
||||
return delegate.unmarshal(in, au);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T unmarshal(InputStream in) throws JAXBException {
|
||||
return delegate.unmarshal(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T unmarshal(Node n, AttachmentUnmarshaller au) throws JAXBException {
|
||||
return delegate.unmarshal(n, au);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getTypeInfo() {
|
||||
return delegate.getTypeInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportOutputStream() {
|
||||
return delegate.supportOutputStream();
|
||||
}
|
||||
|
||||
static public interface CollectionHandler {
|
||||
int getSize(Object c);
|
||||
Iterator iterator(Object c);
|
||||
Object convert(List list);
|
||||
}
|
||||
|
||||
static class BaseCollectionHandler implements CollectionHandler {
|
||||
Class type;
|
||||
BaseCollectionHandler(Class c) {type = c;}
|
||||
@Override
|
||||
public int getSize(Object c) { return ((Collection) c).size(); }
|
||||
@Override
|
||||
public Object convert(List list) {
|
||||
try {
|
||||
Object o = type.newInstance();
|
||||
((Collection)o).addAll(list);
|
||||
return o;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public Iterator iterator(Object c) {return ((Collection)c).iterator();}
|
||||
}
|
||||
|
||||
static final CollectionHandler ListHandler = new BaseCollectionHandler(List.class) {
|
||||
@Override
|
||||
public Object convert(List list) {return list;}
|
||||
};
|
||||
|
||||
static final CollectionHandler HashSetHandler = new BaseCollectionHandler(HashSet.class) {
|
||||
@Override
|
||||
public Object convert(List list) { return new HashSet(list);}
|
||||
};
|
||||
|
||||
static public CollectionHandler create(TypeInfo ti) {
|
||||
Class javaClass = (Class) ti.type;
|
||||
if (javaClass.isArray()) {
|
||||
return new ArrayHandler((Class) ti.getItemType().type);
|
||||
} else if (List.class.equals(javaClass) || Collection.class.equals(javaClass)) {
|
||||
return ListHandler;
|
||||
} else if (Set.class.equals(javaClass) || HashSet.class.equals(javaClass)) {
|
||||
return HashSetHandler;
|
||||
} else {
|
||||
return new BaseCollectionHandler(javaClass);
|
||||
}
|
||||
}
|
||||
|
||||
static class ArrayHandler implements CollectionHandler {
|
||||
Class componentClass;
|
||||
public ArrayHandler(Class component) {
|
||||
componentClass = component;
|
||||
}
|
||||
@Override
|
||||
public int getSize(Object c) {
|
||||
return java.lang.reflect.Array.getLength(c);
|
||||
}
|
||||
@Override
|
||||
public Object convert(List list) {
|
||||
Object array = java.lang.reflect.Array.newInstance(componentClass, list.size());
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
java.lang.reflect.Array.set(array, i, list.get(i));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
@Override
|
||||
public Iterator iterator(final Object c) {
|
||||
return new Iterator() {
|
||||
int index = 0;
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (c == null || java.lang.reflect.Array.getLength(c) == 0) {
|
||||
return false;
|
||||
}
|
||||
return (index != java.lang.reflect.Array.getLength(c));
|
||||
}
|
||||
@Override
|
||||
public Object next() throws NoSuchElementException {
|
||||
Object retVal = null;
|
||||
try {
|
||||
retVal = java.lang.reflect.Array.get(c, index++);
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
@Override
|
||||
public void remove() {}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
196
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/TypeInfo.java
Normal file
196
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/TypeInfo.java
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
|
||||
|
||||
/**
|
||||
* A reference to a JAXB-bound type.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public final class TypeInfo {
|
||||
|
||||
/**
|
||||
* The associated XML element name that the JAX-RPC uses with this type reference.
|
||||
*
|
||||
* Always non-null. Strings are interned.
|
||||
*/
|
||||
public final QName tagName;
|
||||
|
||||
/**
|
||||
* The Java type that's being referenced.
|
||||
*
|
||||
* Always non-null.
|
||||
*/
|
||||
public Type type;
|
||||
|
||||
/**
|
||||
* The annotations associated with the reference of this type.
|
||||
*
|
||||
* Always non-null.
|
||||
*/
|
||||
public final Annotation[] annotations;
|
||||
|
||||
private Map<String, Object> properties = new HashMap<String, Object>();
|
||||
|
||||
private boolean isGlobalElement = true;
|
||||
|
||||
private TypeInfo parentCollectionType;
|
||||
|
||||
private Type genericType;
|
||||
|
||||
private boolean nillable = true;
|
||||
|
||||
public TypeInfo(QName tagName, Type type, Annotation... annotations) {
|
||||
if(tagName==null || type==null || annotations==null) {
|
||||
String nullArgs = "";
|
||||
|
||||
if(tagName == null) nullArgs = "tagName";
|
||||
if(type == null) nullArgs += (nullArgs.length() > 0 ? ", type" : "type");
|
||||
if(annotations == null) nullArgs += (nullArgs.length() > 0 ? ", annotations" : "annotations");
|
||||
|
||||
// Messages.ARGUMENT_CANT_BE_NULL.format(nullArgs);
|
||||
|
||||
throw new IllegalArgumentException( "Argument(s) \"" + nullArgs + "\" can''t be null.)");
|
||||
}
|
||||
|
||||
this.tagName = new QName(tagName.getNamespaceURI().intern(), tagName.getLocalPart().intern(), tagName.getPrefix());
|
||||
this.type = type;
|
||||
if (type instanceof Class && ((Class<?>)type).isPrimitive()) nillable = false;
|
||||
this.annotations = annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the specified annotation from the array and returns it.
|
||||
* Null if not found.
|
||||
*/
|
||||
public <A extends Annotation> A get( Class<A> annotationType ) {
|
||||
for (Annotation a : annotations) {
|
||||
if(a.annotationType()==annotationType)
|
||||
return annotationType.cast(a);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link TypeInfo} for the item type,
|
||||
* if this {@link TypeInfo} represents a collection type.
|
||||
* Otherwise returns an identical type.
|
||||
*/
|
||||
public TypeInfo toItemType() {
|
||||
// if we are to reinstitute this check, check JAXB annotations only
|
||||
// assert annotations.length==0; // not designed to work with adapters.
|
||||
Type t = (genericType != null)? genericType : type;
|
||||
Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(t, Collection.class);
|
||||
if(base==null)
|
||||
return this; // not a collection
|
||||
|
||||
return new TypeInfo(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0));
|
||||
}
|
||||
|
||||
public Map<String, Object> properties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public boolean isGlobalElement() {
|
||||
return isGlobalElement;
|
||||
}
|
||||
|
||||
public void setGlobalElement(boolean isGlobalElement) {
|
||||
this.isGlobalElement = isGlobalElement;
|
||||
}
|
||||
|
||||
public TypeInfo getParentCollectionType() {
|
||||
return parentCollectionType;
|
||||
}
|
||||
|
||||
public void setParentCollectionType(TypeInfo parentCollectionType) {
|
||||
this.parentCollectionType = parentCollectionType;
|
||||
}
|
||||
|
||||
public boolean isRepeatedElement() {
|
||||
return (parentCollectionType != null);
|
||||
}
|
||||
|
||||
public Type getGenericType() {
|
||||
return genericType;
|
||||
}
|
||||
|
||||
public void setGenericType(Type genericType) {
|
||||
this.genericType = genericType;
|
||||
}
|
||||
|
||||
public boolean isNillable() {
|
||||
return nillable;
|
||||
}
|
||||
|
||||
public void setNillable(boolean nillable) {
|
||||
this.nillable = nillable;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new StringBuilder("TypeInfo: Type = ").append(type)
|
||||
.append(", tag = ").append(tagName).toString();
|
||||
}
|
||||
|
||||
public TypeInfo getItemType() {
|
||||
// System.out.println("????? TypeInfo " + type);
|
||||
if (type instanceof Class && ((Class)type).isArray() && !byte[].class.equals(type)) {
|
||||
Type componentType = ((Class)type).getComponentType();
|
||||
Type genericComponentType = null;
|
||||
if (genericType!= null && genericType instanceof GenericArrayType) {
|
||||
GenericArrayType arrayType = (GenericArrayType) type;
|
||||
genericComponentType = arrayType.getGenericComponentType();
|
||||
componentType = arrayType.getGenericComponentType();
|
||||
}
|
||||
TypeInfo ti =new TypeInfo(tagName, componentType, annotations);
|
||||
if (genericComponentType != null) ti.setGenericType(genericComponentType);
|
||||
return ti;
|
||||
}
|
||||
// if (type instanceof Class && java.util.Collection.class.isAssignableFrom((Class)type)) {
|
||||
Type t = (genericType != null)? genericType : type;
|
||||
Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(t, Collection.class);
|
||||
if ( base != null) {
|
||||
return new TypeInfo(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0), annotations);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
94
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/Utils.java
Normal file
94
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/Utils.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Utils class.
|
||||
*
|
||||
* WARNING: If you are doing any changes don't forget to change other Utils classes in different packages.
|
||||
*
|
||||
* Has *package private* access to avoid inappropriate usage.
|
||||
*/
|
||||
final class Utils {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Utils.class.getName());
|
||||
|
||||
/**
|
||||
* static ReflectionNavigator field to avoid usage of reflection every time we use it.
|
||||
*/
|
||||
static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR;
|
||||
|
||||
static { // we statically initializing REFLECTION_NAVIGATOR property
|
||||
try {
|
||||
final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
|
||||
|
||||
// requires accessClassInPackage privilege
|
||||
final Method getInstance = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Method>() {
|
||||
@Override
|
||||
public Method run() {
|
||||
try {
|
||||
Method getInstance = refNav.getDeclaredMethod("getInstance");
|
||||
getInstance.setAccessible(true);
|
||||
return getInstance;
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//noinspection unchecked
|
||||
REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IllegalStateException("Can't find ReflectionNavigator class");
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
|
||||
} catch (SecurityException e) {
|
||||
LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* private constructor to avoid util class instantiating
|
||||
*/
|
||||
private Utils() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* WrapperAccessor
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public abstract class WrapperAccessor {
|
||||
protected Map<Object, PropertySetter> propertySetters;
|
||||
protected Map<Object, PropertyGetter> propertyGetters;
|
||||
protected boolean elementLocalNameCollision;
|
||||
|
||||
protected PropertySetter getPropertySetter(QName name) {
|
||||
Object key = (elementLocalNameCollision) ? name : name.getLocalPart();
|
||||
return propertySetters.get(key);
|
||||
}
|
||||
protected PropertyGetter getPropertyGetter(QName name) {
|
||||
Object key = (elementLocalNameCollision) ? name : name.getLocalPart();
|
||||
return propertyGetters.get(key);
|
||||
}
|
||||
|
||||
public PropertyAccessor getPropertyAccessor(String ns, String name) {
|
||||
QName n = new QName(ns, name);
|
||||
final PropertySetter setter = getPropertySetter(n);
|
||||
final PropertyGetter getter = getPropertyGetter(n);
|
||||
return new PropertyAccessor() {
|
||||
public Object get(Object bean) throws DatabindingException {
|
||||
return getter.get(bean);
|
||||
}
|
||||
|
||||
public void set(Object bean, Object value) throws DatabindingException {
|
||||
setter.set(bean, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
213
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/WrapperBridge.java
Normal file
213
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/WrapperBridge.java
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.attachment.AttachmentMarshaller;
|
||||
import javax.xml.bind.attachment.AttachmentUnmarshaller;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
//import com.sun.xml.internal.ws.spi.db.BindingContext;
|
||||
//import com.sun.xml.internal.ws.spi.db.RepeatedElementBridge;
|
||||
//import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
//import com.sun.xml.internal.ws.spi.db.DatabindingException;
|
||||
//import com.sun.xml.internal.ws.spi.db.TypeInfo;
|
||||
//import com.sun.xml.internal.ws.spi.db.WrapperComposite;
|
||||
|
||||
/**
|
||||
* WrapperBridge handles RPC-Literal body and Document-Literal wrappers without static
|
||||
* wrapper classes.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class WrapperBridge<T> implements XMLBridge<T> {
|
||||
|
||||
BindingContext parent;
|
||||
TypeInfo typeInfo;
|
||||
static final String WrapperPrefix = "w";
|
||||
static final String WrapperPrefixColon = WrapperPrefix + ":";
|
||||
|
||||
public WrapperBridge(BindingContext p, TypeInfo ti) {
|
||||
this.parent = p;
|
||||
this.typeInfo = ti;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingContext context() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeInfo getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
|
||||
WrapperComposite w = (WrapperComposite) object;
|
||||
Attributes att = new Attributes() {
|
||||
@Override public int getLength() { return 0; }
|
||||
@Override public String getURI(int index) { return null; }
|
||||
@Override public String getLocalName(int index) { return null; }
|
||||
@Override public String getQName(int index) { return null; }
|
||||
@Override public String getType(int index) { return null; }
|
||||
@Override public String getValue(int index) { return null; }
|
||||
@Override public int getIndex(String uri, String localName) { return 0; }
|
||||
@Override public int getIndex(String qName) { return 0; }
|
||||
@Override public String getType(String uri, String localName) { return null; }
|
||||
@Override public String getType(String qName) { return null; }
|
||||
@Override public String getValue(String uri, String localName) { return null; }
|
||||
@Override public String getValue(String qName) { return null; }
|
||||
};
|
||||
try {
|
||||
contentHandler.startPrefixMapping(WrapperPrefix, typeInfo.tagName.getNamespaceURI());
|
||||
contentHandler.startElement(typeInfo.tagName.getNamespaceURI(), typeInfo.tagName.getLocalPart(), WrapperPrefixColon + typeInfo.tagName.getLocalPart(), att);
|
||||
} catch (SAXException e) {
|
||||
throw new JAXBException(e);
|
||||
}
|
||||
if (w.bridges != null) for (int i = 0; i < w.bridges.length; i++) {
|
||||
if (w.bridges[i] instanceof RepeatedElementBridge) {
|
||||
RepeatedElementBridge rbridge = (RepeatedElementBridge) w.bridges[i];
|
||||
for (Iterator itr = rbridge.collectionHandler().iterator(w.values[i]); itr.hasNext();) {
|
||||
rbridge.marshal(itr.next(), contentHandler, am);
|
||||
}
|
||||
} else {
|
||||
w.bridges[i].marshal(w.values[i], contentHandler, am);
|
||||
}
|
||||
}
|
||||
try {
|
||||
contentHandler.endElement(typeInfo.tagName.getNamespaceURI(), typeInfo.tagName.getLocalPart(), null);
|
||||
contentHandler.endPrefixMapping(WrapperPrefix);
|
||||
} catch (SAXException e) {
|
||||
throw new JAXBException(e);
|
||||
}
|
||||
// bridge.marshal(object, contentHandler, am);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(T object, Node output) throws JAXBException {
|
||||
throw new UnsupportedOperationException();
|
||||
// bridge.marshal(object, output);
|
||||
// bridge.marshal((T) convert(object), output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(T object, OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
|
||||
// bridge.marshal((T) convert(object), output, nsContext, am);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void marshal(T object, Result result) throws JAXBException {
|
||||
throw new UnsupportedOperationException();
|
||||
// bridge.marshal(object, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void marshal(T object, XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
|
||||
WrapperComposite w = (WrapperComposite) object;
|
||||
try {
|
||||
// output.writeStartElement(typeInfo.tagName.getNamespaceURI(), typeInfo.tagName.getLocalPart());
|
||||
// System.out.println(typeInfo.tagName.getNamespaceURI());
|
||||
|
||||
//The prefix is to workaround an eclipselink bug
|
||||
String prefix = output.getPrefix(typeInfo.tagName.getNamespaceURI());
|
||||
if (prefix == null) prefix = WrapperPrefix;
|
||||
output.writeStartElement(prefix, typeInfo.tagName.getLocalPart(), typeInfo.tagName.getNamespaceURI());
|
||||
output.writeNamespace(prefix, typeInfo.tagName.getNamespaceURI());
|
||||
|
||||
// output.writeStartElement("", typeInfo.tagName.getLocalPart(), typeInfo.tagName.getNamespaceURI());
|
||||
// output.writeDefaultNamespace(typeInfo.tagName.getNamespaceURI());
|
||||
// System.out.println("======== " + output.getPrefix(typeInfo.tagName.getNamespaceURI()));
|
||||
// System.out.println("======== " + output.getNamespaceContext().getPrefix(typeInfo.tagName.getNamespaceURI()));
|
||||
// System.out.println("======== " + output.getNamespaceContext().getNamespaceURI(""));
|
||||
} catch (XMLStreamException e) {
|
||||
e.printStackTrace();
|
||||
throw new DatabindingException(e);
|
||||
}
|
||||
if (w.bridges != null) for (int i = 0; i < w.bridges.length; i++) {
|
||||
if (w.bridges[i] instanceof RepeatedElementBridge) {
|
||||
RepeatedElementBridge rbridge = (RepeatedElementBridge) w.bridges[i];
|
||||
for (Iterator itr = rbridge.collectionHandler().iterator(w.values[i]); itr.hasNext();) {
|
||||
rbridge.marshal(itr.next(), output, am);
|
||||
}
|
||||
} else {
|
||||
w.bridges[i].marshal(w.values[i], output, am);
|
||||
}
|
||||
}
|
||||
try {
|
||||
output.writeEndElement();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new DatabindingException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T unmarshal(InputStream in) throws JAXBException {
|
||||
//EndpointArgumentsBuilder.RpcLit.readRequest
|
||||
throw new UnsupportedOperationException();
|
||||
// return bridge.unmarshal(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T unmarshal(Node n, AttachmentUnmarshaller au) throws JAXBException {
|
||||
//EndpointArgumentsBuilder.RpcLit.readRequest
|
||||
throw new UnsupportedOperationException();
|
||||
// return bridge.unmarshal(n, au);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T unmarshal(Source in, AttachmentUnmarshaller au) throws JAXBException {
|
||||
//EndpointArgumentsBuilder.RpcLit.readRequest
|
||||
throw new UnsupportedOperationException();
|
||||
// return bridge.unmarshal(in, au);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T unmarshal(XMLStreamReader in, AttachmentUnmarshaller au) throws JAXBException {
|
||||
//EndpointArgumentsBuilder.RpcLit.readRequest
|
||||
throw new UnsupportedOperationException();
|
||||
// return bridge.unmarshal(in, au);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportOutputStream() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
/**
|
||||
* A JAXB Bean that works like a DOM.
|
||||
*
|
||||
* <p>
|
||||
* This bean is bound to XML as a sequence of elements, where each
|
||||
* element[i] is from bridges[i] (which defines the tag name and the expected type)
|
||||
* and values[i] (which defines the actual value.)
|
||||
*
|
||||
* <p>
|
||||
* This object allows you to treat multiple unrelated JAXB beans as a single tree.
|
||||
* This in turn allows you to marshal this tree in one marshal method invocation,
|
||||
* which is faster than multiple invocations of the marshal method.
|
||||
*
|
||||
* <p>
|
||||
* The binding of this class is always known to {@link BindingContext}, so it can be
|
||||
* used without passing anything to {@link BindingContext#newWrapperInstace(Class)}.
|
||||
* This object can be only used for marshalling, not for unmarshalling.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class WrapperComposite {
|
||||
public XMLBridge[] bridges;
|
||||
public Object[] values;
|
||||
}
|
||||
244
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/XMLBridge.java
Normal file
244
jdkSrc/jdk8/com/sun/xml/internal/ws/spi/db/XMLBridge.java
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.spi.db;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.attachment.AttachmentMarshaller;
|
||||
import javax.xml.bind.attachment.AttachmentUnmarshaller;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.ContentHandler;
|
||||
|
||||
/**
|
||||
* The XMLBridge is a Glassfish JAXWS side of Glassfish JAXB Bridge.
|
||||
*
|
||||
* Mini-marshaller/unmarshaller that is specialized for a particular
|
||||
* element name and a type.
|
||||
*
|
||||
* <p>
|
||||
* Instances of this class is stateless and multi-thread safe.
|
||||
* They are reentrant.
|
||||
*
|
||||
* <p>
|
||||
* All the marshal operation generates fragments.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @since JAXB 2.0 EA1
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface XMLBridge<T> {
|
||||
/**
|
||||
* Gets the {@link BindingContext} to which this object belongs.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public @NotNull BindingContext context();
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while marshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
// public void marshal(T object,XMLStreamWriter output) throws JAXBException;
|
||||
|
||||
public void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Marshals the specified type object with the implicit element name
|
||||
* associated with this instance of {@link Bond}.
|
||||
*
|
||||
* @param nsContext
|
||||
* if this marshalling is done to marshal a subelement, this {@link NamespaceContext}
|
||||
* represents in-scope namespace bindings available for that element. Can be null,
|
||||
* in which case JAXB assumes no in-scope namespaces.
|
||||
* @throws JAXBException
|
||||
* if there was an error while marshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
// public void marshal(T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
|
||||
|
||||
/**
|
||||
* @since 2.0.2
|
||||
*/
|
||||
public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException ;
|
||||
//
|
||||
//// public void marshal(@NotNull BridgeContext context,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
|
||||
//
|
||||
// public void marshal(@NotNull Marshaller m,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
|
||||
|
||||
|
||||
public void marshal(T object,Node output) throws JAXBException ;
|
||||
//
|
||||
//// public void marshal(@NotNull BridgeContext context,T object,Node output) throws JAXBException ;
|
||||
//
|
||||
// public void marshal(@NotNull Marshaller m,T object,Node output) throws JAXBException;
|
||||
|
||||
|
||||
/**
|
||||
* @since 2.0 EA4
|
||||
*/
|
||||
// public void marshal(T object, ContentHandler contentHandler) throws JAXBException;
|
||||
/**
|
||||
* @since 2.0.2
|
||||
*/
|
||||
public void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException ;
|
||||
|
||||
//// public void marshal(@NotNull BridgeContext context,T object, ContentHandler contentHandler) throws JAXBException;
|
||||
//
|
||||
// public void marshal(@NotNull Marshaller m,T object, ContentHandler contentHandler) throws JAXBException;
|
||||
|
||||
/**
|
||||
* @since 2.0 EA4
|
||||
*/
|
||||
public void marshal(T object, Result result) throws JAXBException;
|
||||
|
||||
//// public void marshal(@NotNull BridgeContext context,T object, Result result) throws JAXBException;
|
||||
// public void marshal(@NotNull Marshaller m,T object, Result result) throws JAXBException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link Bond} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
// public @NotNull T unmarshal(@NotNull XMLStreamReader in) throws JAXBException ;
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public @NotNull T unmarshal(@NotNull XMLStreamReader in, @Nullable AttachmentUnmarshaller au) throws JAXBException;
|
||||
// public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull XMLStreamReader in) throws JAXBException ;
|
||||
// public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull XMLStreamReader in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link Bond} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
// public @NotNull T unmarshal(@NotNull Source in) throws JAXBException ;
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public @NotNull T unmarshal(@NotNull Source in, @Nullable AttachmentUnmarshaller au) throws JAXBException;
|
||||
// public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Source in) throws JAXBException;
|
||||
// public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull Source in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link XMLBridge} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public @NotNull T unmarshal(@NotNull InputStream in) throws JAXBException ;
|
||||
|
||||
// public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull InputStream in) throws JAXBException ;
|
||||
|
||||
// public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull InputStream in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param n
|
||||
* Node to be unmarshalled.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 FCS
|
||||
*/
|
||||
// public @NotNull T unmarshal(@NotNull Node n) throws JAXBException ;
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public @NotNull T unmarshal(@NotNull Node n, @Nullable AttachmentUnmarshaller au) throws JAXBException;
|
||||
// public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Node n) throws JAXBException;
|
||||
// public @NotNull T unmarshal(@NotNull Unmarshaller context, @NotNull Node n) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Gets the {@link TypeInfo} from which this bridge was created.
|
||||
*/
|
||||
public TypeInfo getTypeInfo();
|
||||
|
||||
/**
|
||||
* This can be used to determine whether XMLStreamWriter or OutputStream is
|
||||
* prefered by the implementation.
|
||||
*
|
||||
* @return true if marshall to OutputStream is supported in the
|
||||
* implementation.
|
||||
*/
|
||||
public boolean supportOutputStream();
|
||||
}
|
||||
Reference in New Issue
Block a user