001 /*
002 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.xml.ws.spi;
027
028 import javax.xml.ws.Endpoint;
029 import javax.xml.ws.WebServiceException;
030 import javax.xml.namespace.QName;
031
032 /**
033 * Service provider for <code>ServiceDelegate</code> and
034 * <code>Endpoint</code> objects.
035 * <p>
036 *
037 * @since JAX-WS 2.0
038 */
039 public abstract class Provider {
040
041 /**
042 * A constant representing the property used to lookup the
043 * name of a <code>Provider</code> implementation
044 * class.
045 */
046 static public final String JAXWSPROVIDER_PROPERTY = "javax.xml.ws.spi.Provider";
047
048 /**
049 * A constant representing the name of the default
050 * <code>Provider</code> implementation class.
051 **/
052 static private final String DEFAULT_JAXWSPROVIDER = "com.sun.xml.internal.ws.spi.ProviderImpl";
053
054 /**
055 * Creates a new instance of Provider
056 */
057 protected Provider() {
058 }
059
060 /**
061 *
062 * Creates a new provider object.
063 * <p>
064 * The algorithm used to locate the provider subclass to use consists
065 * of the following steps:
066 * <p>
067 * <ul>
068 * <li>
069 * If a resource with the name of
070 * <code>META-INF/services/javax.xml.ws.spi.Provider</code>
071 * exists, then its first line, if present, is used as the UTF-8 encoded
072 * name of the implementation class.
073 * </li>
074 * <li>
075 * If the $java.home/lib/jaxws.properties file exists and it is readable by
076 * the <code>java.util.Properties.load(InputStream)</code> method and it contains
077 * an entry whose key is <code>javax.xml.ws.spi.Provider</code>, then the value of
078 * that entry is used as the name of the implementation class.
079 * </li>
080 * <li>
081 * If a system property with the name <code>javax.xml.ws.spi.Provider</code>
082 * is defined, then its value is used as the name of the implementation class.
083 * </li>
084 * <li>
085 * Finally, a default implementation class name is used.
086 * </li>
087 * </ul>
088 *
089 */
090 public static Provider provider() {
091 try {
092 return (Provider) FactoryFinder.find(
093 JAXWSPROVIDER_PROPERTY, DEFAULT_JAXWSPROVIDER);
094 } catch (WebServiceException ex) {
095 throw ex;
096 } catch (Exception ex) {
097 throw new WebServiceException("Unable to create Provider: "
098 + ex.getMessage());
099 }
100
101 }
102
103 /**
104 * Creates a service delegate object.
105 * <p>
106 * @param wsdlDocumentLocation A URL pointing to the WSDL document
107 * for the service, or <code>null</code> if there isn't one.
108 * @param serviceName The qualified name of the service.
109 * @param serviceClass The service class, which must be either
110 * <code>javax.xml.ws.Service</code> or a subclass thereof.
111 * @return The newly created service delegate.
112 */
113 public abstract ServiceDelegate createServiceDelegate(
114 java.net.URL wsdlDocumentLocation, QName serviceName,
115 Class serviceClass);
116
117 /**
118 *
119 * Creates an endpoint object with the provided binding and implementation
120 * object.
121 *
122 * @param bindingId A URI specifying the desired binding (e.g. SOAP/HTTP)
123 * @param implementor A service implementation object to which
124 * incoming requests will be dispatched. The corresponding
125 * class must be annotated with all the necessary Web service
126 * annotations.
127 * @return The newly created endpoint.
128 */
129 public abstract Endpoint createEndpoint(String bindingId,
130 Object implementor);
131
132 /**
133 * Creates and publishes an endpoint object with the specified
134 * address and implementation object.
135 *
136 * @param address A URI specifying the address and transport/protocol
137 * to use. A http: URI must result in the SOAP 1.1/HTTP
138 * binding being used. Implementations may support other
139 * URI schemes.
140 * @param implementor A service implementation object to which
141 * incoming requests will be dispatched. The corresponding
142 * class must be annotated with all the necessary Web service
143 * annotations.
144 * @return The newly created endpoint.
145 */
146 public abstract Endpoint createAndPublishEndpoint(String address,
147 Object implementor);
148 }
|