feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,216 @@
/*
* Copyright (c) 2005, 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 javax.xml.ws.spi;
import java.io.*;
import java.util.Properties;
import javax.xml.ws.WebServiceException;
class FactoryFinder {
/**
* Creates an instance of the specified class using the specified
* <code>ClassLoader</code> object.
*
* @exception WebServiceException if the given class could not be found
* or could not be instantiated
*/
private static Object newInstance(String className,
ClassLoader classLoader)
{
try {
Class spiClass = safeLoadClass(className, classLoader);
return spiClass.newInstance();
} catch (ClassNotFoundException x) {
throw new WebServiceException(
"Provider " + className + " not found", x);
} catch (Exception x) {
throw new WebServiceException(
"Provider " + className + " could not be instantiated: " + x,
x);
}
}
/**
* Finds the implementation <code>Class</code> object for the given
* factory name, or if that fails, finds the <code>Class</code> object
* for the given fallback class name. The arguments supplied MUST be
* used in order. If using the first argument is successful, the second
* one will not be used.
* <P>
* This method is package private so that this code can be shared.
*
* @return the <code>Class</code> object of the specified message factory;
* may not be <code>null</code>
*
* @param factoryId the name of the factory to find, which is
* a system property
* @param fallbackClassName the implementation class name, which is
* to be used only if nothing else
* is found; <code>null</code> to indicate that
* there is no fallback class name
* @exception WebServiceException if there is an error
*/
static Object find(String factoryId, String fallbackClassName)
{
if (isOsgi()) {
return lookupUsingOSGiServiceLoader(factoryId);
}
ClassLoader classLoader;
try {
classLoader = Thread.currentThread().getContextClassLoader();
} catch (Exception x) {
throw new WebServiceException(x.toString(), x);
}
String serviceId = "META-INF/services/" + factoryId;
// try to find services in CLASSPATH
BufferedReader rd = null;
try {
InputStream is;
if (classLoader == null) {
is=ClassLoader.getSystemResourceAsStream(serviceId);
} else {
is=classLoader.getResourceAsStream(serviceId);
}
if( is!=null ) {
rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String factoryClassName = rd.readLine();
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
return newInstance(factoryClassName, classLoader);
}
}
} catch( Exception ignored) {
} finally {
close(rd);
}
// try to read from $java.home/lib/jaxws.properties
FileInputStream inStream = null;
try {
String javah=System.getProperty( "java.home" );
String configFile = javah + File.separator +
"lib" + File.separator + "jaxws.properties";
File f=new File( configFile );
if( f.exists()) {
Properties props=new Properties();
inStream = new FileInputStream(f);
props.load(inStream);
String factoryClassName = props.getProperty(factoryId);
return newInstance(factoryClassName, classLoader);
}
} catch(Exception ignored) {
} finally {
close(inStream);
}
// Use the system property
try {
String systemProp =
System.getProperty( factoryId );
if( systemProp!=null) {
return newInstance(systemProp, classLoader);
}
} catch (SecurityException ignored) {
}
if (fallbackClassName == null) {
throw new WebServiceException(
"Provider for " + factoryId + " cannot be found", null);
}
return newInstance(fallbackClassName, classLoader);
}
private static void close(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException ignored) {
}
}
}
/**
* Loads the class, provided that the calling thread has an access to the class being loaded.
*/
private static Class safeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
try {
// make sure that the current thread has an access to the package of the given name.
SecurityManager s = System.getSecurityManager();
if (s != null) {
int i = className.lastIndexOf('.');
if (i != -1) {
s.checkPackageAccess(className.substring(0, i));
}
}
if (classLoader == null)
return Class.forName(className);
else
return classLoader.loadClass(className);
} catch (SecurityException se) {
// anyone can access the platform default factory class without permission
if (Provider.DEFAULT_JAXWSPROVIDER.equals(className))
return Class.forName(className);
throw se;
}
}
private static final String OSGI_SERVICE_LOADER_CLASS_NAME = "com.sun.org.glassfish.hk2.osgiresourcelocator.ServiceLoader";
private static boolean isOsgi() {
try {
Class.forName(OSGI_SERVICE_LOADER_CLASS_NAME);
return true;
} catch (ClassNotFoundException ignored) {
}
return false;
}
private static Object lookupUsingOSGiServiceLoader(String factoryId) {
try {
// Use reflection to avoid having any dependendcy on ServiceLoader class
Class serviceClass = Class.forName(factoryId);
Class[] args = new Class[]{serviceClass};
Class target = Class.forName(OSGI_SERVICE_LOADER_CLASS_NAME);
java.lang.reflect.Method m = target.getMethod("lookupProviderInstances", Class.class);
java.util.Iterator iter = ((Iterable) m.invoke(null, (Object[]) args)).iterator();
return iter.hasNext() ? iter.next() : null;
} catch (Exception ignored) {
// log and continue
return null;
}
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2009, 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 javax.xml.ws.spi;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceFeature;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
/**
* Invoker hides the detail of calling into application endpoint
* implementation. Container hands over an implementation of Invoker
* to JAX-WS runtime, and jax-ws runtime calls {@link #invoke}
* for a web service invocation. Finally, Invoker does the actual
* invocation of web service on endpoint instance.
*
* Container also injects the provided <code>WebServiceContext</code> and takes
* care of invoking <code>javax.annotation.PostConstruct</code> methods,
* if present, on the endpoint implementation.
*
* @see Provider#createEndpoint(String, Class, Invoker, WebServiceFeature...)
* @author Jitendra Kotamraju
* @since JAX-WS 2.2
*/
public abstract class Invoker {
/**
* JAX-WS runtimes calls this method to ask container to inject
* WebServiceContext on the endpoint instance. The
* <code>WebServiceContext</code> object uses thread-local information
* to return the correct information during the actual endpoint invocation
* regardless of how many threads are concurrently being used to serve
* requests.
*
* @param webServiceContext a holder for MessageContext
* @throws IllegalAccessException if the injection done
* by reflection API throws this exception
* @throws IllegalArgumentException if the injection done
* by reflection API throws this exception
* @throws InvocationTargetException if the injection done
* by reflection API throws this exception
*/
public abstract void inject(WebServiceContext webServiceContext)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
/**
* JAX-WS runtime calls this method to do the actual web service
* invocation on endpoint instance. The injected
* <code>WebServiceContext.getMessageContext()</code> gives the correct
* information for this invocation.
*
* @param m Method to be invoked on the service
* @param args Method arguments
* @return return value of the method
* @throws IllegalAccessException if the invocation done
* by reflection API throws this exception
* @throws IllegalArgumentException if the invocation done
* by reflection API throws this exception
* @throws InvocationTargetException if the invocation done
* by reflection API throws this exception
* @see Method#invoke
*/
public abstract Object invoke(Method m, Object... args)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
}

View File

@@ -0,0 +1,521 @@
/*
* Copyright (c) 2005, 2011, 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 javax.xml.ws.spi;
import java.net.URL;
import java.util.List;
import java.util.Iterator;
import java.util.Map;
import java.lang.reflect.Method;
import javax.xml.namespace.QName;
import javax.xml.ws.*;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.w3c.dom.Element;
/**
* Service provider for <code>ServiceDelegate</code> and
* <code>Endpoint</code> objects.
* <p>
*
* @since JAX-WS 2.0
*/
public abstract class Provider {
/**
* A constant representing the property used to lookup the
* name of a <code>Provider</code> implementation
* class.
*/
static public final String JAXWSPROVIDER_PROPERTY
= "javax.xml.ws.spi.Provider";
/**
* A constant representing the name of the default
* <code>Provider</code> implementation class.
**/
// Using two strings so that package renaming doesn't change it
static final String DEFAULT_JAXWSPROVIDER
= "com.sun"+".xml.internal.ws.spi.ProviderImpl";
/**
* Take advantage of Java SE 6's java.util.ServiceLoader API.
* Using reflection so that there is no compile-time dependency on SE 6.
*/
static private final Method loadMethod;
static private final Method iteratorMethod;
static {
Method tLoadMethod = null;
Method tIteratorMethod = null;
try {
Class<?> clazz = Class.forName("java.util.ServiceLoader");
tLoadMethod = clazz.getMethod("load", Class.class);
tIteratorMethod = clazz.getMethod("iterator");
} catch(ClassNotFoundException ce) {
// Running on Java SE 5
} catch(NoSuchMethodException ne) {
// Shouldn't happen
}
loadMethod = tLoadMethod;
iteratorMethod = tIteratorMethod;
}
/**
* Creates a new instance of Provider
*/
protected Provider() {
}
/**
*
* Creates a new provider object.
* <p>
* The algorithm used to locate the provider subclass to use consists
* of the following steps:
* <p>
* <ul>
* <li>
* If a resource with the name of
* <code>META-INF/services/javax.xml.ws.spi.Provider</code>
* exists, then its first line, if present, is used as the UTF-8 encoded
* name of the implementation class.
* </li>
* <li>
* If the $java.home/lib/jaxws.properties file exists and it is readable by
* the <code>java.util.Properties.load(InputStream)</code> method and it contains
* an entry whose key is <code>javax.xml.ws.spi.Provider</code>, then the value of
* that entry is used as the name of the implementation class.
* </li>
* <li>
* If a system property with the name <code>javax.xml.ws.spi.Provider</code>
* is defined, then its value is used as the name of the implementation class.
* </li>
* <li>
* Finally, a default implementation class name is used.
* </li>
* </ul>
*
*/
public static Provider provider() {
try {
Object provider = getProviderUsingServiceLoader();
if (provider == null) {
provider = FactoryFinder.find(JAXWSPROVIDER_PROPERTY, DEFAULT_JAXWSPROVIDER);
}
if (!(provider instanceof Provider)) {
Class pClass = Provider.class;
String classnameAsResource = pClass.getName().replace('.', '/') + ".class";
ClassLoader loader = pClass.getClassLoader();
if(loader == null) {
loader = ClassLoader.getSystemClassLoader();
}
URL targetTypeURL = loader.getResource(classnameAsResource);
throw new LinkageError("ClassCastException: attempting to cast" +
provider.getClass().getClassLoader().getResource(classnameAsResource) +
"to" + targetTypeURL.toString() );
}
return (Provider) provider;
} catch (WebServiceException ex) {
throw ex;
} catch (Exception ex) {
throw new WebServiceException("Unable to createEndpointReference Provider", ex);
}
}
private static Provider getProviderUsingServiceLoader() {
if (loadMethod != null) {
Object loader;
try {
loader = loadMethod.invoke(null, Provider.class);
} catch (Exception e) {
throw new WebServiceException("Cannot invoke java.util.ServiceLoader#load()", e);
}
Iterator<Provider> it;
try {
it = (Iterator<Provider>)iteratorMethod.invoke(loader);
} catch(Exception e) {
throw new WebServiceException("Cannot invoke java.util.ServiceLoader#iterator()", e);
}
return it.hasNext() ? it.next() : null;
}
return null;
}
/**
* Creates a service delegate object.
* <p>
* @param wsdlDocumentLocation A URL pointing to the WSDL document
* for the service, or <code>null</code> if there isn't one.
* @param serviceName The qualified name of the service.
* @param serviceClass The service class, which MUST be either
* <code>javax.xml.ws.Service</code> or a subclass thereof.
* @return The newly created service delegate.
*/
public abstract ServiceDelegate createServiceDelegate(
java.net.URL wsdlDocumentLocation,
QName serviceName, Class<? extends Service> serviceClass);
/**
* Creates a service delegate object.
* <p>
* @param wsdlDocumentLocation A URL pointing to the WSDL document
* for the service, or <code>null</code> if there isn't one.
* @param serviceName The qualified name of the service.
* @param serviceClass The service class, which MUST be either
* <code>javax.xml.ws.Service</code> or a subclass thereof.
* @param features Web Service features that must be configured on
* the service. If the provider doesn't understand a feature,
* it must throw a WebServiceException.
* @return The newly created service delegate.
*
* @since JAX-WS 2.2
*/
public ServiceDelegate createServiceDelegate(
java.net.URL wsdlDocumentLocation,
QName serviceName, Class<? extends Service> serviceClass, WebServiceFeature ... features) {
throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
}
/**
*
* Creates an endpoint object with the provided binding and implementation
* object.
*
* @param bindingId A URI specifying the desired binding (e.g. SOAP/HTTP)
* @param implementor A service implementation object to which
* incoming requests will be dispatched. The corresponding
* class MUST be annotated with all the necessary Web service
* annotations.
* @return The newly created endpoint.
*/
public abstract Endpoint createEndpoint(String bindingId,
Object implementor);
/**
* Creates and publishes an endpoint object with the specified
* address and implementation object.
*
* @param address A URI specifying the address and transport/protocol
* to use. A http: URI MUST result in the SOAP 1.1/HTTP
* binding being used. Implementations may support other
* URI schemes.
* @param implementor A service implementation object to which
* incoming requests will be dispatched. The corresponding
* class MUST be annotated with all the necessary Web service
* annotations.
* @return The newly created endpoint.
*/
public abstract Endpoint createAndPublishEndpoint(String address,
Object implementor);
/**
* read an EndpointReference from the infoset contained in
* <code>eprInfoset</code>.
*
* @param eprInfoset infoset for EndpointReference
*
* @return the <code>EndpointReference</code> unmarshalled from
* <code>eprInfoset</code>. This method never returns <code>null</code>.
*
* @throws WebServiceException If there is an error creating the
* <code>EndpointReference</code> from the specified <code>eprInfoset</code>.
*
* @throws NullPointerException If the <code>null</code>
* <code>eprInfoset</code> value is given.
*
* @since JAX-WS 2.1
**/
public abstract EndpointReference readEndpointReference(javax.xml.transform.Source eprInfoset);
/**
* The getPort method returns a proxy. If there
* are any reference parameters in the
* <code>endpointReference</code>, then those reference
* parameters MUST appear as SOAP headers, indicating them to be
* reference parameters, on all messages sent to the endpoint.
* The parameter <code>serviceEndpointInterface</code> specifies
* the service endpoint interface that is supported by the
* returned proxy.
* The parameter <code>endpointReference</code> specifies the
* endpoint that will be invoked by the returned proxy.
* In the implementation of this method, the JAX-WS
* runtime system takes the responsibility of selecting a protocol
* binding (and a port) and configuring the proxy accordingly from
* the WSDL metadata of the
* <code>serviceEndpointInterface</code> and the <code>EndpointReference</code>.
* For this method
* to successfully return a proxy, WSDL metadata MUST be available and the
* <code>endpointReference</code> MUST contain an implementation understood
* <code>serviceName</code> metadata.
*
*
* @param endpointReference the EndpointReference that will
* be invoked by the returned proxy.
* @param serviceEndpointInterface Service endpoint interface
* @param features A list of WebServiceFeatures to configure on the
* proxy. Supported features not in the <code>features
* </code> parameter will have their default values.
* @return Object Proxy instance that supports the
* specified service endpoint interface
* @throws WebServiceException
* <UL>
* <LI>If there is an error during creation
* of the proxy
* <LI>If there is any missing WSDL metadata
* as required by this method}
* <LI>If this
* <code>endpointReference</code>
* is illegal
* <LI>If an illegal
* <code>serviceEndpointInterface</code>
* is specified
* <LI>If a feature is enabled that is not compatible with
* this port or is unsupported.
* </UL>
*
* @see WebServiceFeature
*
* @since JAX-WS 2.1
**/
public abstract <T> T getPort(EndpointReference endpointReference,
Class<T> serviceEndpointInterface,
WebServiceFeature... features);
/**
* Factory method to create a <code>W3CEndpointReference</code>.
*
* <p>
* This method can be used to create a <code>W3CEndpointReference</code>
* for any endpoint by specifying the <code>address</code> property along
* with any other desired properties. This method
* can also be used to create a <code>W3CEndpointReference</code> for
* an endpoint that is published by the same Java EE application.
* To do so the <code>address</code> property can be provided or this
* method can automatically determine the <code>address</code> of
* an endpoint that is published by the same Java EE application and is
* identified by the <code>serviceName</code> and
* <code>portName</code> propeties. If the <code>address</code> is
* <code>null</code> and the <code>serviceName</code> and
* <code>portName</code> do not identify an endpoint published by the
* same Java EE application, a
* <code>javax.lang.IllegalStateException</code> MUST be thrown.
*
* @param address Specifies the address of the target endpoint
* @param serviceName Qualified name of the service in the WSDL.
* @param portName Qualified name of the endpoint in the WSDL.
* @param metadata A list of elements that should be added to the
* <code>W3CEndpointReference</code> instances <code>wsa:metadata</code>
* element.
* @param wsdlDocumentLocation URL for the WSDL document location for
* the service.
* @param referenceParameters Reference parameters to be associated
* with the returned <code>EndpointReference</code> instance.
*
* @return the <code>W3CEndpointReference</code> created from
* <code>serviceName</code>, <code>portName</code>,
* <code>metadata</code>, <code>wsdlDocumentLocation</code>
* and <code>referenceParameters</code>. This method
* never returns <code>null</code>.
*
* @throws java.lang.IllegalStateException
* <ul>
* <li>If the <code>address</code>, <code>serviceName</code> and
* <code>portName</code> are all <code>null</code>.
* <li>If the <code>serviceName</code> service is <code>null</code> and the
* <code>portName</code> is NOT <code>null</code>.
* <li>If the <code>address</code> property is <code>null</code> and
* the <code>serviceName</code> and <code>portName</code> do not
* specify a valid endpoint published by the same Java EE
* application.
* <li>If the <code>serviceName</code>is NOT <code>null</code>
* and is not present in the specified WSDL.
* <li>If the <code>portName</code> port is not <code>null</code> and it
* is not present in <code>serviceName</code> service in the WSDL.
* <li>If the <code>wsdlDocumentLocation</code> is NOT <code>null</code>
* and does not represent a valid WSDL.
* </ul>
* @throws WebServiceException If an error occurs while creating the
* <code>W3CEndpointReference</code>.
*
* @since JAX-WS 2.1
*/
public abstract W3CEndpointReference createW3CEndpointReference(String address, QName serviceName, QName portName,
List<Element> metadata, String wsdlDocumentLocation, List<Element> referenceParameters);
/**
* Factory method to create a <code>W3CEndpointReference</code>.
* Using this method, a <code>W3CEndpointReference</code> instance
* can be created with extension elements, and attributes.
* <code>Provider</code> implementations must override the default
* implementation.
*
* <p>
* This method can be used to create a <code>W3CEndpointReference</code>
* for any endpoint by specifying the <code>address</code> property along
* with any other desired properties. This method
* can also be used to create a <code>W3CEndpointReference</code> for
* an endpoint that is published by the same Java EE application.
* To do so the <code>address</code> property can be provided or this
* method can automatically determine the <code>address</code> of
* an endpoint that is published by the same Java EE application and is
* identified by the <code>serviceName</code> and
* <code>portName</code> propeties. If the <code>address</code> is
* <code>null</code> and the <code>serviceName</code> and
* <code>portName</code> do not identify an endpoint published by the
* same Java EE application, a
* <code>javax.lang.IllegalStateException</code> MUST be thrown.
*
* @param address Specifies the address of the target endpoint
* @param interfaceName the <code>wsam:InterfaceName</code> element in the
* <code>wsa:Metadata</code> element.
* @param serviceName Qualified name of the service in the WSDL.
* @param portName Qualified name of the endpoint in the WSDL.
* @param metadata A list of elements that should be added to the
* <code>W3CEndpointReference</code> instances <code>wsa:metadata</code>
* element.
* @param wsdlDocumentLocation URL for the WSDL document location for
* the service.
* @param referenceParameters Reference parameters to be associated
* with the returned <code>EndpointReference</code> instance.
* @param elements extension elements to be associated
* with the returned <code>EndpointReference</code> instance.
* @param attributes extension attributes to be associated
* with the returned <code>EndpointReference</code> instance.
*
* @return the <code>W3CEndpointReference</code> created from
* <code>serviceName</code>, <code>portName</code>,
* <code>metadata</code>, <code>wsdlDocumentLocation</code>
* and <code>referenceParameters</code>. This method
* never returns <code>null</code>.
*
* @throws java.lang.IllegalStateException
* <ul>
* <li>If the <code>address</code>, <code>serviceName</code> and
* <code>portName</code> are all <code>null</code>.
* <li>If the <code>serviceName</code> service is <code>null</code> and the
* <code>portName</code> is NOT <code>null</code>.
* <li>If the <code>address</code> property is <code>null</code> and
* the <code>serviceName</code> and <code>portName</code> do not
* specify a valid endpoint published by the same Java EE
* application.
* <li>If the <code>serviceName</code>is NOT <code>null</code>
* and is not present in the specified WSDL.
* <li>If the <code>portName</code> port is not <code>null</code> and it
* is not present in <code>serviceName</code> service in the WSDL.
* <li>If the <code>wsdlDocumentLocation</code> is NOT <code>null</code>
* and does not represent a valid WSDL.
* <li>If the <code>wsdlDocumentLocation</code> is NOT <code>null</code> but
* wsdli:wsdlLocation's namespace name cannot be got from the available
* metadata.
* </ul>
* @throws WebServiceException If an error occurs while creating the
* <code>W3CEndpointReference</code>.
* @since JAX-WS 2.2
*/
public W3CEndpointReference createW3CEndpointReference(String address,
QName interfaceName, QName serviceName, QName portName,
List<Element> metadata, String wsdlDocumentLocation, List<Element> referenceParameters,
List<Element> elements, Map<QName, String> attributes) {
throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
}
/**
* Creates and publishes an endpoint object with the specified
* address, implementation object and web service features.
* <code>Provider</code> implementations must override the
* default implementation.
*
* @param address A URI specifying the address and transport/protocol
* to use. A http: URI MUST result in the SOAP 1.1/HTTP
* binding being used. Implementations may support other
* URI schemes.
* @param implementor A service implementation object to which
* incoming requests will be dispatched. The corresponding
* class MUST be annotated with all the necessary Web service
* annotations.
* @param features A list of WebServiceFeatures to configure on the
* endpoint. Supported features not in the <code>features
* </code> parameter will have their default values.
* @return The newly created endpoint.
* @since JAX-WS 2.2
*/
public Endpoint createAndPublishEndpoint(String address,
Object implementor, WebServiceFeature ... features) {
throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
}
/**
* Creates an endpoint object with the provided binding, implementation
* object and web service features. <code>Provider</code> implementations
* must override the default implementation.
*
* @param bindingId A URI specifying the desired binding (e.g. SOAP/HTTP)
* @param implementor A service implementation object to which
* incoming requests will be dispatched. The corresponding
* class MUST be annotated with all the necessary Web service
* annotations.
* @param features A list of WebServiceFeatures to configure on the
* endpoint. Supported features not in the <code>features
* </code> parameter will have their default values.
* @return The newly created endpoint.
* @since JAX-WS 2.2
*/
public Endpoint createEndpoint(String bindingId, Object implementor,
WebServiceFeature ... features) {
throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
}
/**
* Creates an endpoint object with the provided binding, implementation
* class, invoker and web service features. Containers typically use
* this to create Endpoint objects. <code>Provider</code>
* implementations must override the default implementation.
*
* @param bindingId A URI specifying the desired binding (e.g. SOAP/HTTP).
* Can be null.
* @param implementorClass A service implementation class that
* MUST be annotated with all the necessary Web service
* annotations.
* @param invoker that does the actual invocation on the service instance.
* @param features A list of WebServiceFeatures to configure on the
* endpoint. Supported features not in the <code>features
* </code> parameter will have their default values.
* @return The newly created endpoint.
* @since JAX-WS 2.2
*/
public Endpoint createEndpoint(String bindingId, Class<?> implementorClass,
Invoker invoker, WebServiceFeature ... features) {
throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
}
}

View File

@@ -0,0 +1,622 @@
/*
* Copyright (c) 2005, 2010, 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 javax.xml.ws.spi;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.WebServiceFeature;
import javax.xml.bind.JAXBContext;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceException;
/**
* Service delegates are used internally by <code>Service</code> objects
* to allow pluggability of JAX-WS implementations.
* <p>
* Every <code>Service</code> object has its own delegate, created using
* the {@link javax.xml.ws.spi.Provider#createServiceDelegate} method. A <code>Service</code>
* object delegates all of its instance methods to its delegate.
*
* @see javax.xml.ws.Service
* @see javax.xml.ws.spi.Provider
*
* @since JAX-WS 2.0
*/
public abstract class ServiceDelegate {
protected ServiceDelegate() {
}
/**
* The <code>getPort</code> method returns a proxy. A service client
* uses this proxy to invoke operations on the target
* service endpoint. The <code>serviceEndpointInterface</code>
* specifies the service endpoint interface that is supported by
* the created dynamic proxy instance.
*
* @param portName Qualified name of the service endpoint in
* the WSDL service description
* @param serviceEndpointInterface Service endpoint interface
* supported by the dynamic proxy
* @return Object Proxy instance that
* supports the specified service endpoint
* interface
* @throws WebServiceException This exception is thrown in the
* following cases:
* <UL>
* <LI>If there is an error in creation of
* the proxy
* <LI>If there is any missing WSDL metadata
* as required by this method
* <LI>If an illegal
* <code>serviceEndpointInterface</code>
* or <code>portName</code> is specified
* </UL>
* @see java.lang.reflect.Proxy
* @see java.lang.reflect.InvocationHandler
**/
public abstract <T> T getPort(QName portName,
Class<T> serviceEndpointInterface);
/**
* The <code>getPort</code> method returns a proxy. A service client
* uses this proxy to invoke operations on the target
* service endpoint. The <code>serviceEndpointInterface</code>
* specifies the service endpoint interface that is supported by
* the created dynamic proxy instance.
*
* @param portName Qualified name of the service endpoint in
* the WSDL service description
* @param serviceEndpointInterface Service endpoint interface
* supported by the dynamic proxy or instance
* @param features A list of WebServiceFeatures to configure on the
* proxy. Supported features not in the <code>features
* </code> parameter will have their default values.
* @return Object Proxy instance that
* supports the specified service endpoint
* interface
* @throws WebServiceException This exception is thrown in the
* following cases:
* <UL>
* <LI>If there is an error in creation of
* the proxy
* <LI>If there is any missing WSDL metadata
* as required by this method
* <LI>If an illegal
* <code>serviceEndpointInterface</code>
* or <code>portName</code> is specified
* <LI>If a feature is enabled that is not compatible
* with this port or is unsupported.
* </UL>
* @see java.lang.reflect.Proxy
* @see java.lang.reflect.InvocationHandler
* @see WebServiceFeature
*
* @since JAX-WS 2.1
**/
public abstract <T> T getPort(QName portName,
Class<T> serviceEndpointInterface, WebServiceFeature... features);
/**
* The <code>getPort</code> method returns a proxy.
* The parameter <code>endpointReference</code> specifies the
* endpoint that will be invoked by the returned proxy. If there
* are any reference parameters in the
* <code>endpointReference</code>, then those reference
* parameters MUST appear as SOAP headers, indicating them to be
* reference parameters, on all messages sent to the endpoint.
* The <code>endpointReference's</code> address MUST be used
* for invocations on the endpoint.
* The parameter <code>serviceEndpointInterface</code> specifies
* the service endpoint interface that is supported by the
* returned proxy.
* In the implementation of this method, the JAX-WS
* runtime system takes the responsibility of selecting a protocol
* binding (and a port) and configuring the proxy accordingly from
* the WSDL associated with this <code>Service</code> instance or
* from the metadata from the <code>endpointReference</code>.
* If this <code>Service</code> instance has a WSDL and
* the <code>endpointReference</code> metadata
* also has a WSDL, then the WSDL from this instance MUST be used.
* If this <code>Service</code> instance does not have a WSDL and
* the <code>endpointReference</code> does have a WSDL, then the
* WSDL from the <code>endpointReference</code> MAY be used.
* The returned proxy should not be reconfigured by the client.
* If this <code>Service</code> instance has a known proxy
* port that matches the information contained in
* the WSDL,
* then that proxy is returned, otherwise a WebServiceException
* is thrown.
* <p>
* Calling this method has the same behavior as the following
* <pre>
* <code>port = service.getPort(portName, serviceEndpointInterface);</code>
* </pre>
* where the <code>portName</code> is retrieved from the
* metadata of the <code>endpointReference</code> or from the
* <code>serviceEndpointInterface</code> and the WSDL
* associated with this <code>Service</code> instance.
*
* @param endpointReference The <code>EndpointReference</code>
* for the target service endpoint that will be invoked by the
* returned proxy.
* @param serviceEndpointInterface Service endpoint interface.
* @param features A list of <code>WebServiceFeatures</code> to configure on the
* proxy. Supported features not in the <code>features
* </code> parameter will have their default values.
* @return Object Proxy instance that supports the
* specified service endpoint interface.
* @throws WebServiceException
* <UL>
* <LI>If there is an error during creation
* of the proxy.
* <LI>If there is any missing WSDL metadata
* as required by this method.
* <LI>If the <code>endpointReference</code> metadata does
* not match the <code>serviceName</code> of this
* <code>Service</code> instance.
* <LI>If a <code>portName</code> cannot be extracted
* from the WSDL or <code>endpointReference</code> metadata.
* <LI>If an invalid
* <code>endpointReference</code>
* is specified.
* <LI>If an invalid
* <code>serviceEndpointInterface</code>
* is specified.
* <LI>If a feature is enabled that is not compatible
* with this port or is unsupported.
* </UL>
*
* @since JAX-WS 2.1
**/
public abstract <T> T getPort(EndpointReference endpointReference,
Class<T> serviceEndpointInterface, WebServiceFeature... features);
/**
* The <code>getPort</code> method returns a proxy. The parameter
* <code>serviceEndpointInterface</code> specifies the service
* endpoint interface that is supported by the returned proxy.
* In the implementation of this method, the JAX-WS
* runtime system takes the responsibility of selecting a protocol
* binding (and a port) and configuring the proxy accordingly.
* The returned proxy should not be reconfigured by the client.
*
* @param serviceEndpointInterface Service endpoint interface
* @return Object instance that supports the
* specified service endpoint interface
* @throws WebServiceException
* <UL>
* <LI>If there is an error during creation
* of the proxy
* <LI>If there is any missing WSDL metadata
* as required by this method
* <LI>If an illegal
* <code>serviceEndpointInterface</code>
* is specified
* </UL>
**/
public abstract <T> T getPort(Class<T> serviceEndpointInterface);
/**
* The <code>getPort</code> method returns a proxy. The parameter
* <code>serviceEndpointInterface</code> specifies the service
* endpoint interface that is supported by the returned proxy.
* In the implementation of this method, the JAX-WS
* runtime system takes the responsibility of selecting a protocol
* binding (and a port) and configuring the proxy accordingly.
* The returned proxy should not be reconfigured by the client.
*
* @param serviceEndpointInterface Service endpoint interface
* @param features An array of <code>WebServiceFeatures</code> to configure on the
* proxy. Supported features not in the <code>features
* </code> parameter will have their default values.
* @return Object instance that supports the
* specified service endpoint interface
* @throws WebServiceException
* <UL>
* <LI>If there is an error during creation
* of the proxy
* <LI>If there is any missing WSDL metadata
* as required by this method
* <LI>If an illegal
* <code>serviceEndpointInterface</code>
* is specified
* <LI>If a feature is enabled that is not compatible
* with this port or is unsupported.
* </UL>
*
* @see WebServiceFeature
*
* @since JAX-WS 2.1
**/
public abstract <T> T getPort(Class<T> serviceEndpointInterface,
WebServiceFeature... features);
/**
* Creates a new port for the service. Ports created in this way contain
* no WSDL port type information and can only be used for creating
* <code>Dispatch</code>instances.
*
* @param portName Qualified name for the target service endpoint
* @param bindingId A URI identifier of a binding.
* @param endpointAddress Address of the target service endpoint as a URI
* @throws WebServiceException If any error in the creation of
* the port
*
* @see javax.xml.ws.soap.SOAPBinding#SOAP11HTTP_BINDING
* @see javax.xml.ws.soap.SOAPBinding#SOAP12HTTP_BINDING
* @see javax.xml.ws.http.HTTPBinding#HTTP_BINDING
**/
public abstract void addPort(QName portName, String bindingId,
String endpointAddress);
/**
* Creates a <code>Dispatch</code> instance for use with objects of
* the user's choosing.
*
* @param portName Qualified name for the target service endpoint
* @param type The class of object used for messages or message
* payloads. Implementations are required to support
* <code>javax.xml.transform.Source</code> and <code>javax.xml.soap.SOAPMessage</code>.
* @param mode Controls whether the created dispatch instance is message
* or payload oriented, i.e. whether the user will work with complete
* protocol messages or message payloads. E.g. when using the SOAP
* protocol, this parameter controls whether the user will work with
* SOAP messages or the contents of a SOAP body. Mode MUST be <code>MESSAGE</code>
* when type is <code>SOAPMessage</code>.
*
* @return Dispatch instance
* @throws WebServiceException If any error in the creation of
* the <code>Dispatch</code> object
* @see javax.xml.transform.Source
* @see javax.xml.soap.SOAPMessage
**/
public abstract <T> Dispatch<T> createDispatch(QName portName, Class<T> type,
Service.Mode mode);
/**
* Creates a <code>Dispatch</code> instance for use with objects of
* the user's choosing.
*
* @param portName Qualified name for the target service endpoint
* @param type The class of object used for messages or message
* payloads. Implementations are required to support
* <code>javax.xml.transform.Source</code> and <code>javax.xml.soap.SOAPMessage</code>.
* @param mode Controls whether the created dispatch instance is message
* or payload oriented, i.e. whether the user will work with complete
* protocol messages or message payloads. E.g. when using the SOAP
* protocol, this parameter controls whether the user will work with
* SOAP messages or the contents of a SOAP body. Mode MUST be <code>MESSAGE</code>
* when type is <code>SOAPMessage</code>.
* @param features A list of <code>WebServiceFeatures</code> to configure on the
* proxy. Supported features not in the <code>features
* </code> parameter will have their default values.
*
* @return Dispatch instance
* @throws WebServiceException If any error in the creation of
* the <code>Dispatch</code> object or if a
* feature is enabled that is not compatible with
* this port or is unsupported.
*
* @see javax.xml.transform.Source
* @see javax.xml.soap.SOAPMessage
* @see WebServiceFeature
*
* @since JAX-WS 2.1
**/
public abstract <T> Dispatch<T> createDispatch(QName portName, Class<T> type,
Service.Mode mode, WebServiceFeature... features);
/**
* Creates a <code>Dispatch</code> instance for use with objects of
* the user's choosing. If there
* are any reference parameters in the
* <code>endpointReference</code>, then those reference
* parameters MUST appear as SOAP headers, indicating them to be
* reference parameters, on all messages sent to the endpoint.
* The <code>endpointReference's</code> address MUST be used
* for invocations on the endpoint.
* In the implementation of this method, the JAX-WS
* runtime system takes the responsibility of selecting a protocol
* binding (and a port) and configuring the dispatch accordingly from
* the WSDL associated with this <code>Service</code> instance or
* from the metadata from the <code>endpointReference</code>.
* If this <code>Service</code> instance has a WSDL and
* the <code>endpointReference</code>
* also has a WSDL in its metadata, then the WSDL from this instance MUST be used.
* If this <code>Service</code> instance does not have a WSDL and
* the <code>endpointReference</code> does have a WSDL, then the
* WSDL from the <code>endpointReference</code> MAY be used.
* An implementation MUST be able to retrieve the <code>portName</code> from the
* <code>endpointReference</code> metadata.
* <p>
* This method behaves the same as calling
* <pre>
* <code>dispatch = service.createDispatch(portName, type, mode, features);</code>
* </pre>
* where the <code>portName</code> is retrieved from the
* WSDL or <code>EndpointReference</code> metadata.
*
* @param endpointReference The <code>EndpointReference</code>
* for the target service endpoint that will be invoked by the
* returned <code>Dispatch</code> object.
* @param type The class of object used to messages or message
* payloads. Implementations are required to support
* <code>javax.xml.transform.Source</code> and <code>javax.xml.soap.SOAPMessage</code>.
* @param mode Controls whether the created dispatch instance is message
* or payload oriented, i.e. whether the user will work with complete
* protocol messages or message payloads. E.g. when using the SOAP
* protocol, this parameter controls whether the user will work with
* SOAP messages or the contents of a SOAP body. Mode MUST be <code>MESSAGE</code>
* when type is <code>SOAPMessage</code>.
* @param features An array of <code>WebServiceFeatures</code> to configure on the
* proxy. Supported features not in the <code>features
* </code> parameter will have their default values.
*
* @return Dispatch instance
* @throws WebServiceException
* <UL>
* <LI>If there is any missing WSDL metadata
* as required by this method.
* <li>If the <code>endpointReference</code> metadata does
* not match the <code>serviceName</code> or <code>portName</code>
* of a WSDL associated
* with this <code>Service</code> instance.
* <li>If the <code>portName</code> cannot be determined
* from the <code>EndpointReference</code> metadata.
* <li>If any error in the creation of
* the <code>Dispatch</code> object.
* <li>If a feature is enabled that is not
* compatible with this port or is unsupported.
* </UL>
*
* @see javax.xml.transform.Source
* @see javax.xml.soap.SOAPMessage
* @see WebServiceFeature
*
* @since JAX-WS 2.1
**/
public abstract <T> Dispatch<T> createDispatch(EndpointReference endpointReference,
Class<T> type, Service.Mode mode,
WebServiceFeature... features);
/**
* Creates a <code>Dispatch</code> instance for use with JAXB
* generated objects.
*
* @param portName Qualified name for the target service endpoint
* @param context The JAXB context used to marshall and unmarshall
* messages or message payloads.
* @param mode Controls whether the created dispatch instance is message
* or payload oriented, i.e. whether the user will work with complete
* protocol messages or message payloads. E.g. when using the SOAP
* protocol, this parameter controls whether the user will work with
* SOAP messages or the contents of a SOAP body.
*
* @return Dispatch instance
* @throws WebServiceException If any error in the creation of
* the <code>Dispatch</code> object
*
* @see javax.xml.bind.JAXBContext
**/
public abstract Dispatch<Object> createDispatch(QName portName,
JAXBContext context, Service.Mode mode);
/**
* Creates a <code>Dispatch</code> instance for use with JAXB
* generated objects.
*
* @param portName Qualified name for the target service endpoint
* @param context The JAXB context used to marshall and unmarshall
* messages or message payloads.
* @param mode Controls whether the created dispatch instance is message
* or payload oriented, i.e. whether the user will work with complete
* protocol messages or message payloads. E.g. when using the SOAP
* protocol, this parameter controls whether the user will work with
* SOAP messages or the contents of a SOAP body.
* @param features A list of <code>WebServiceFeatures</code> to configure on the
* proxy. Supported features not in the <code>features
* </code> parameter will have their default values.
*
* @return Dispatch instance
* @throws WebServiceException If any error in the creation of
* the <code>Dispatch</code> object or if a
* feature is enabled that is not compatible with
* this port or is unsupported.
*
* @see javax.xml.bind.JAXBContext
* @see WebServiceFeature
*
* @since JAX-WS 2.1
**/
public abstract Dispatch<Object> createDispatch(QName portName,
JAXBContext context, Service.Mode mode, WebServiceFeature... features);
/**
* Creates a <code>Dispatch</code> instance for use with JAXB
* generated objects. If there
* are any reference parameters in the
* <code>endpointReference</code>, then those reference
* parameters MUST appear as SOAP headers, indicating them to be
* reference parameters, on all messages sent to the endpoint.
* The <code>endpointReference's</code> address MUST be used
* for invocations on the endpoint.
* In the implementation of this method, the JAX-WS
* runtime system takes the responsibility of selecting a protocol
* binding (and a port) and configuring the dispatch accordingly from
* the WSDL associated with this <code>Service</code> instance or
* from the metadata from the <code>endpointReference</code>.
* If this <code>Service</code> instance has a WSDL and
* the <code>endpointReference</code>
* also has a WSDL in its metadata, then the WSDL from this instance
* MUST be used.
* If this <code>Service</code> instance does not have a WSDL and
* the <code>endpointReference</code> does have a WSDL, then the
* WSDL from the <code>endpointReference</code> MAY be used.
* An implementation MUST be able to retrieve the <code>portName</code> from the
* <code>endpointReference</code> metadata.
* <p>
* This method behavies the same as calling
* <pre>
* <code>dispatch = service.createDispatch(portName, context, mode, features);</code>
* </pre>
* where the <code>portName</code> is retrieved from the
* WSDL or <code>endpointReference</code> metadata.
*
* @param endpointReference The <code>EndpointReference</code>
* for the target service endpoint that will be invoked by the
* returned <code>Dispatch</code> object.
* @param context The JAXB context used to marshall and unmarshall
* messages or message payloads.
* @param mode Controls whether the created dispatch instance is message
* or payload oriented, i.e. whether the user will work with complete
* protocol messages or message payloads. E.g. when using the SOAP
* protocol, this parameter controls whether the user will work with
* SOAP messages or the contents of a SOAP body.
* @param features An array of <code>WebServiceFeatures</code> to configure on the
* proxy. Supported features not in the <code>features
* </code> parameter will have their default values.
*
* @return Dispatch instance
* @throws WebServiceException
* <UL>
* <li>If there is any missing WSDL metadata
* as required by this method.
* <li>If the <code>endpointReference</code> metadata does
* not match the <code>serviceName</code> or <code>portName</code>
* of a WSDL associated
* with this <code>Service</code> instance.
* <li>If the <code>portName</code> cannot be determined
* from the <code>EndpointReference</code> metadata.
* <li>If any error in the creation of
* the <code>Dispatch</code> object.
* <li>if a feature is enabled that is not
* compatible with this port or is unsupported.
* </UL>
*
* @see javax.xml.bind.JAXBContext
* @see WebServiceFeature
*
* @since JAX-WS 2.1
**/
public abstract Dispatch<Object> createDispatch(EndpointReference endpointReference,
JAXBContext context, Service.Mode mode,
WebServiceFeature... features);
/**
* Gets the name of this service.
* @return Qualified name of this service
**/
public abstract QName getServiceName();
/**
* Returns an <code>Iterator</code> for the list of
* <code>QName</code>s of service endpoints grouped by this
* service
*
* @return Returns <code>java.util.Iterator</code> with elements
* of type <code>javax.xml.namespace.QName</code>
* @throws WebServiceException If this Service class does not
* have access to the required WSDL metadata
**/
public abstract Iterator<javax.xml.namespace.QName> getPorts();
/**
* Gets the location of the WSDL document for this Service.
*
* @return URL for the location of the WSDL document for
* this service
**/
public abstract java.net.URL getWSDLDocumentLocation();
/**
* Returns the configured handler resolver.
*
* @return HandlerResolver The <code>HandlerResolver</code> being
* used by this <code>Service</code> instance, or <code>null</code>
* if there isn't one.
**/
public abstract HandlerResolver getHandlerResolver();
/**
* Sets the <code>HandlerResolver</code> for this <code>Service</code>
* instance.
* <p>
* The handler resolver, if present, will be called once for each
* proxy or dispatch instance that is created, and the handler chain
* returned by the resolver will be set on the instance.
*
* @param handlerResolver The <code>HandlerResolver</code> to use
* for all subsequently created proxy/dispatch objects.
*
* @see javax.xml.ws.handler.HandlerResolver
**/
public abstract void setHandlerResolver(HandlerResolver handlerResolver);
/**
* Returns the executor for this <code>Service</code>instance.
*
* The executor is used for all asynchronous invocations that
* require callbacks.
*
* @return The <code>java.util.concurrent.Executor</code> to be
* used to invoke a callback.
*
* @see java.util.concurrent.Executor
**/
public abstract java.util.concurrent.Executor getExecutor();
/**
* Sets the executor for this <code>Service</code> instance.
*
* The executor is used for all asynchronous invocations that
* require callbacks.
*
* @param executor The <code>java.util.concurrent.Executor</code>
* to be used to invoke a callback.
*
* @throws SecurityException If the instance does not support
* setting an executor for security reasons (e.g. the
* necessary permissions are missing).
*
* @see java.util.concurrent.Executor
**/
public abstract void setExecutor(java.util.concurrent.Executor executor);
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2005, 2010, 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 javax.xml.ws.spi;
import java.lang.annotation.Documented;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.WebServiceRef;
import javax.xml.ws.WebServiceRefs;
import javax.xml.ws.RespectBinding;
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.MTOM;
/**
* Annotation used to identify other annotations
* as a <code>WebServiceFeature</code>.
* <p>
* Each <code>WebServiceFeature</code> annotation annotated with
* this annotation MUST contain an
* <code>enabled</code> property of type
* <code>boolean</code> with a default value of <code>true</code>.
* <p>
* JAX-WS defines the following
* <code>WebServiceFeature</code> annotations (<code>Addressing</code>,
* <code>MTOM</code>, <code>RespectBinding</code>), however, an implementation
* may define vendors specific annotations for other features.
* <p>
* Annotations annotated with <code>WebServiceFeatureAnnotation</code> MUST
* have the same @Target of {@link WebServiceRef} annotation, so that the resulting
* feature annotation can be used in conjunction with the {@link WebServiceRef}
* annotation if necessary.
* <p>
* If a JAX-WS implementation encounters an annotation annotated
* with the <code>WebServiceFeatureAnnotation</code> that it does not
* recognize/support an error MUST be given.
* <p>
*
* @see Addressing
* @see MTOM
* @see RespectBinding
*
* @since JAX-WS 2.1
*/
@Target(ElementType.ANNOTATION_TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface WebServiceFeatureAnnotation {
/**
* Unique identifier for the WebServiceFeature. This
* identifier MUST be unique across all implementations
* of JAX-WS.
*/
String id();
/**
* The <code>WebServiceFeature</code> bean that is associated
* with the <code>WebServiceFeature</code> annotation
*/
Class<? extends WebServiceFeature> bean();
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 2009, 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 javax.xml.ws.spi.http;
import javax.xml.ws.Endpoint;
import java.util.Set;
/**
* HttpContext represents a mapping between the root URI path of a web
* service to a {@link HttpHandler} which is invoked to handle requests
* destined for that path on the associated container.
* <p>
* Container provides the implementation for this and it matches
* web service requests to corresponding HttpContext objects.
*
* @author Jitendra Kotamraju
* @since JAX-WS 2.2
*/
public abstract class HttpContext {
protected HttpHandler handler;
/**
* JAX-WS runtime sets its handler during
* {@link Endpoint#publish(HttpContext)} to handle
* HTTP requests for this context. Container or its extensions
* use this handler to process the requests.
*
* @param handler the handler to set for this context
*/
public void setHandler(HttpHandler handler) {
this.handler = handler;
}
/**
* Returns the path for this context. This path uniquely identifies
* an endpoint inside an application and the path is relative to
* application's context path. Container should give this
* path based on how it matches request URIs to this HttpContext object.
*
* <p>
* For servlet container, this is typically a url-pattern for an endpoint.
*
* <p>
* Endpoint's address for this context can be computed as follows:
* <pre>
* HttpExchange exch = ...;
* String endpointAddress =
* exch.getScheme() + "://"
* + exch.getLocalAddress().getHostName()
* + ":" + exch.getLocalAddress().getPort()
* + exch.getContextPath() + getPath();
* </pre>
*
* @return this context's path
*/
public abstract String getPath();
/**
* Returns an attribute value for container's configuration
* and other data that can be used by jax-ws runtime.
*
* @param name attribute name
* @return attribute value
*/
public abstract Object getAttribute(String name);
/**
* Returns all attribute names for container's configuration
* and other data that can be used by jax-ws runtime.
*
* @return set of all attribute names
*/
public abstract Set<String> getAttributeNames();
}

View File

@@ -0,0 +1,328 @@
/*
* Copyright (c) 2005, 2010, 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 javax.xml.ws.spi.http;
import javax.xml.ws.handler.MessageContext;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.security.Principal;
/**
* This class encapsulates a HTTP request received and a
* response to be generated in one exchange. It provides methods
* for examining the request from the client, and for building and
* sending the response.
* <p>
* A <code>HttpExchange</code> must be closed to free or reuse
* underlying resources. The effect of failing to close an exchange
* is undefined.
*
* @author Jitendra Kotamraju
* @since JAX-WS 2.2
*/
public abstract class HttpExchange {
/**
* Standard property: cipher suite value when the request is received
* over HTTPS
* <p>Type: String
*/
public static final String REQUEST_CIPHER_SUITE =
"javax.xml.ws.spi.http.request.cipher.suite";
/**
* Standard property: bit size of the algorithm when the request is
* received over HTTPS
* <p>Type: Integer
*/
public static final String REQUEST_KEY_SIZE =
"javax.xml.ws.spi.http.request.key.size";
/**
* Standard property: A SSL certificate, if any, associated with the request
*
* <p>Type: java.security.cert.X509Certificate[]
* The order of this array is defined as being in ascending order of trust.
* The first certificate in the chain is the one set by the client, the next
* is the one used to authenticate the first, and so on.
*/
public static final String REQUEST_X509CERTIFICATE =
"javax.xml.ws.spi.http.request.cert.X509Certificate";
/**
* Returns an immutable Map containing the HTTP headers that were
* included with this request. The keys in this Map will be the header
* names, while the values will be a List of Strings containing each value
* that was included (either for a header that was listed several times,
* or one that accepts a comma-delimited list of values on a single line).
* In either of these cases, the values for the header name will be
* presented in the order that they were included in the request.
* <p>
* The keys in Map are case-insensitive.
*
* @return an immutable Map which can be used to access request headers
*/
public abstract Map<String, List<String>> getRequestHeaders();
/**
* Returns the value of the specified request header. If the request
* did not include a header of the specified name, this method returns
* null. If there are multiple headers with the same name, this method
* returns the first header in the request. The header name is
* case-insensitive. This is a convienence method to get a header
* (instead of using the {@link #getRequestHeaders}).
*
* @param name the name of the request header
* @return returns the value of the requested header,
* or null if the request does not have a header of that name
*/
public abstract String getRequestHeader(String name);
/**
* Returns a mutable Map into which the HTTP response headers can be stored
* and which will be transmitted as part of this response. The keys in the
* Map will be the header names, while the values must be a List of Strings
* containing each value that should be included multiple times
* (in the order that they should be included).
* <p>
* The keys in Map are case-insensitive.
*
* @return a mutable Map which can be used to set response headers.
*/
public abstract Map<String, List<String>> getResponseHeaders();
/**
* Adds a response header with the given name and value. This method
* allows a response header to have multiple values. This is a
* convenience method to add a response header(instead of using the
* {@link #getResponseHeaders()}).
*
* @param name the name of the header
* @param value the additional header value. If it contains octet string,
* it should be encoded according to
* RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
*
* @see #getResponseHeaders
*/
public abstract void addResponseHeader(String name, String value);
/**
* Returns the part of the request's URI from the protocol
* name up to the query string in the first line of the HTTP request.
* Container doesn't decode this string.
*
* @return the request URI
*/
public abstract String getRequestURI();
/**
* Returns the context path of all the endpoints in an application.
* This path is the portion of the request URI that indicates the
* context of the request. The context path always comes first in a
* request URI. The path starts with a "/" character but does not
* end with a "/" character. If this method returns "", the request
* is for default context. The container does not decode this string.
*
* <p>
* Context path is used in computing the endpoint address. See
* {@link HttpContext#getPath}
*
* @return context path of all the endpoints in an application
* @see HttpContext#getPath
*/
public abstract String getContextPath();
/**
* Get the HTTP request method
*
* @return the request method
*/
public abstract String getRequestMethod();
/**
* Returns a {@link HttpContext} for this exchange.
* Container matches the request with the associated Endpoint's HttpContext
*
* @return the HttpContext for this exchange
*/
public abstract HttpContext getHttpContext();
/**
* This must be called to end an exchange. Container takes care of
* closing request and response streams. This must be called so that
* the container can free or reuse underlying resources.
*
* @throws IOException if any i/o error
*/
public abstract void close() throws IOException;
/**
* Returns a stream from which the request body can be read.
* Multiple calls to this method will return the same stream.
*
* @return the stream from which the request body can be read.
* @throws IOException if any i/o error during request processing
*/
public abstract InputStream getRequestBody() throws IOException;
/**
* Returns a stream to which the response body must be
* written. {@link #setStatus}) must be called prior to calling
* this method. Multiple calls to this method (for the same exchange)
* will return the same stream.
*
* @return the stream to which the response body is written
* @throws IOException if any i/o error during response processing
*/
public abstract OutputStream getResponseBody() throws IOException;
/**
* Sets the HTTP status code for the response.
*
* <p>
* This method must be called prior to calling {@link #getResponseBody}.
*
* @param status the response code to send
* @see #getResponseBody
*/
public abstract void setStatus(int status);
/**
* Returns the unresolved address of the remote entity invoking
* this request.
*
* @return the InetSocketAddress of the caller
*/
public abstract InetSocketAddress getRemoteAddress();
/**
* Returns the unresolved local address on which the request was received.
*
* @return the InetSocketAddress of the local interface
*/
public abstract InetSocketAddress getLocalAddress();
/**
* Returns the protocol string from the request in the form
* <i>protocol/majorVersion.minorVersion</i>. For example,
* "HTTP/1.1"
*
* @return the protocol string from the request
*/
public abstract String getProtocol();
/**
* Returns the name of the scheme used to make this request,
* for example: http, or https.
*
* @return name of the scheme used to make this request
*/
public abstract String getScheme();
/**
* Returns the extra path information that follows the web service
* path but precedes the query string in the request URI and will start
* with a "/" character.
*
* <p>
* This can be used for {@link MessageContext#PATH_INFO}
*
* @return decoded extra path information of web service.
* It is the path that comes
* after the web service path but before the query string in the
* request URI
* <tt>null</tt> if there is no extra path in the request URI
*/
public abstract String getPathInfo();
/**
* Returns the query string that is contained in the request URI
* after the path.
*
* <p>
* This can be used for {@link MessageContext#QUERY_STRING}
*
* @return undecoded query string of request URI, or
* <tt>null</tt> if the request URI doesn't have one
*/
public abstract String getQueryString();
/**
* Returns an attribute that is associated with this
* <code>HttpExchange</code>. JAX-WS handlers and endpoints may then
* access the attribute via {@link MessageContext}.
* <p>
* Servlet containers must expose {@link MessageContext#SERVLET_CONTEXT},
* {@link MessageContext#SERVLET_REQUEST}, and
* {@link MessageContext#SERVLET_RESPONSE}
* as attributes.
*
* <p>If the request has been received by the container using HTTPS, the
* following information must be exposed as attributes. These attributes
* are {@link #REQUEST_CIPHER_SUITE}, and {@link #REQUEST_KEY_SIZE}.
* If there is a SSL certificate associated with the request, it must
* be exposed using {@link #REQUEST_X509CERTIFICATE}
*
* @param name attribute name
* @return the attribute value, or <tt>null</tt> if the attribute doesn't
* exist
*/
public abstract Object getAttribute(String name);
/**
* Gives all the attribute names that are associated with
* this <code>HttpExchange</code>.
*
* @return set of all attribute names
* @see #getAttribute(String)
*/
public abstract Set<String> getAttributeNames();
/**
* Returns the {@link Principal} that represents the authenticated
* user for this <code>HttpExchange</code>.
*
* @return Principal for an authenticated user, or
* <tt>null</tt> if not authenticated
*/
public abstract Principal getUserPrincipal();
/**
* Indicates whether an authenticated user is included in the specified
* logical "role".
*
* @param role specifies the name of the role
* @return <tt>true</tt> if the user making this request belongs to a
* given role
*/
public abstract boolean isUserInRole(String role);
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2009, 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 javax.xml.ws.spi.http;
import javax.xml.ws.Endpoint;
import java.io.IOException;
/**
* A handler which is invoked to process HTTP requests.
* <p>
* JAX-WS runtime provides the implementation for this and sets
* it using {@link HttpContext#setHandler(HttpHandler)} during
* {@link Endpoint#publish(HttpContext) }
*
* @author Jitendra Kotamraju
* @since JAX-WS 2.2
*/
public abstract class HttpHandler {
/**
* Handles a given request and generates an appropriate response.
* See {@link HttpExchange} for a description of the steps
* involved in handling an exchange. Container invokes this method
* when it receives an incoming request.
*
* @param exchange the exchange containing the request from the
* client and used to send the response
* @throws IOException when an I/O error happens during request
* handling
*/
public abstract void handle(HttpExchange exchange) throws IOException;
}

View File

@@ -0,0 +1,95 @@
/*
* Copyright (c) 2009, 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.
*/
/**
Provides HTTP SPI that is used for portable deployment of JAX-WS
web services in containers(for e.g. servlet containers). This SPI
is not for end developers but provides a way for the container
developers to deploy JAX-WS services portably.
<p>
The portable deployment is done as below:
<ol>
<li>Container creates {@link javax.xml.ws.Endpoint} objects for an
application. The necessary information to create Endpoint objects
may be got from web service deployment descriptor files.</li>
<li>Container needs to create {@link javax.xml.ws.spi.http.HttpContext}
objects for the deployment. For example, a HttpContext could be
created using servlet configuration(for e.g url-pattern) for the
web service in servlet container case.</li>
<li>Then publishes all the endpoints using
{@link javax.xml.ws.Endpoint#publish(HttpContext)}. During publish(),
JAX-WS runtime registers a {@link javax.xml.ws.spi.http.HttpHandler}
callback to handle incoming requests or
{@link javax.xml.ws.spi.http.HttpExchange} objects. The HttpExchange
object encapsulates a HTTP request and a response.
</ol>
<pre>
Container JAX-WS runtime
--------- --------------
1. Creates Invoker1, ... InvokerN
2. Provider.createEndpoint(...) --> 3. creates Endpoint1
configures Endpoint1
...
4. Provider.createEndpoint(...) --> 5. creates EndpointN
configures EndpointN
6. Creates ApplicationContext
7. creates HttpContext1, ... HttpContextN
8. Endpoint1.publish(HttpContext1) --> 9. creates HttpHandler1
HttpContext1.setHandler(HttpHandler1)
...
10. EndpointN.publish(HttpContextN) --> 11. creates HttpHandlerN
HttpContextN.setHandler(HttpHandlerN)
</pre>
The request processing is done as below(for every request):
<pre>
Container JAX-WS runtime
--------- --------------
1. Creates a HttpExchange
2. Gets handler from HttpContext
3. HttpHandler.handle(HttpExchange) --> 4. reads request from HttpExchange
<-- 5. Calls Invoker
6. Invokes the actual instance
7. Writes the response to HttpExchange
</pre>
<p>
The portable undeployment is done as below:
<pre>
Container
---------
1. @preDestroy on instances
2. Endpoint1.stop()
...
3. EndpointN.stop()
</pre>
@author Jitendra Kotamraju
@since JAX-WS 2.2
*/
package javax.xml.ws.spi.http;