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;
027
028 import java.util.List;
029 import java.util.Map;
030 import javax.xml.ws.spi.Provider;
031
032 /**
033 * A Web service endpoint.
034 *
035 * <p>Endpoints are created using the static methods defined in this
036 * class. An endpoint is always tied to one <code>Binding</code>
037 * and one implementor, both set at endpoint creation time.
038 *
039 * <p>An endpoint is either in a published or an unpublished state.
040 * The <code>publish</code> methods can be used to start publishing
041 * an endpoint, at which point it starts accepting incoming requests.
042 * Conversely, the <code>stop</code> method can be used to stop
043 * accepting incoming requests and take the endpoint down.
044 * Once stopped, an endpoint cannot be published again.
045 *
046 * <p>An <code>Executor</code> may be set on the endpoint in order
047 * to gain better control over the threads used to dispatch incoming
048 * requests. For instance, thread pooling with certain parameters
049 * can be enabled by creating a <code>ThreadPoolExecutor</code> and
050 * registering it with the endpoint.
051 *
052 * <p>Handler chains can be set using the contained <code>Binding</code>.
053 *
054 * <p>An endpoint may have a list of metadata documents, such as WSDL
055 * and XMLSchema documents, bound to it. At publishing time, the
056 * JAX-WS implementation will try to reuse as much of that metadata
057 * as possible instead of generating new one based on the annotations
058 * present on the implementor.
059 *
060 * @since JAX-WS 2.0
061 *
062 * @see javax.xml.ws.Binding
063 * @see javax.xml.ws.BindingType
064 * @see javax.xml.ws.soap.SOAPBinding
065 * @see java.util.concurrent.Executor
066 *
067 **/
068 public abstract class Endpoint {
069
070 /** Standard property: name of WSDL service.
071 * <p>Type: javax.xml.namespace.QName
072 **/
073 public static final String WSDL_SERVICE = "javax.xml.ws.wsdl.service";
074
075 /** Standard property: name of WSDL port.
076 * <p>Type: javax.xml.namespace.QName
077 **/
078 public static final String WSDL_PORT = "javax.xml.ws.wsdl.port";
079
080 /**
081 * Creates an endpoint with the specified implementor object. If there is
082 * a binding specified via a BindingType annotation then it MUST be used else
083 * a default of SOAP 1.1 / HTTP binding MUST be used.
084 * <p>
085 * The newly created endpoint may be published by calling
086 * one of the javax.xml.ws.Endpoint#publish(String) and
087 * javax.xml.ws.Endpoint#publish(Object) methods.
088 *
089 *
090 * @param implementor The endpoint implementor.
091 *
092 * @return The newly created endpoint.
093 *
094 **/
095 public static Endpoint create(Object implementor) {
096 return create(null, implementor);
097 }
098
099 /**
100 * Creates an endpoint with the specified binding type and
101 * implementor object.
102 * <p>
103 * The newly created endpoint may be published by calling
104 * one of the javax.xml.ws.Endpoint#publish(String) and
105 * javax.xml.ws.Endpoint#publish(Object) methods.
106 *
107 * @param bindingId A URI specifying the binding to use. If the bindingID is
108 * <code>null</code> and no binding is specified via a BindingType
109 * annotation then a default SOAP 1.1 / HTTP binding MUST be used.
110 *
111 * @param implementor The endpoint implementor.
112 *
113 * @return The newly created endpoint.
114 *
115 **/
116 public static Endpoint create(String bindingId, Object implementor) {
117 return Provider.provider().createEndpoint(bindingId,
118 implementor);
119 }
120
121 /**
122 * Returns the binding for this endpoint.
123 *
124 * @return The binding for this endpoint
125 **/
126 public abstract Binding getBinding();
127
128 /**
129 * Returns the implementation object for this endpoint.
130 *
131 * @return The implementor for this endpoint
132 **/
133 public abstract Object getImplementor();
134
135 /**
136 * Publishes this endpoint at the given address.
137 * The necessary server infrastructure will be created and
138 * configured by the JAX-WS implementation using some default configuration.
139 * In order to get more control over the server configuration, please
140 * use the javax.xml.ws.Endpoint#publish(Object) method instead.
141 *
142 * @param address A URI specifying the address to use. The address
143 * must be compatible with the binding specified at the
144 * time the endpoint was created.
145 *
146 * @throws java.lang.IllegalArgumentException
147 * If the provided address URI is not usable
148 * in conjunction with the endpoint's binding.
149 *
150 * @throws java.lang.IllegalStateException
151 * If the endpoint has been published already or it has been stopped.
152 **/
153 public abstract void publish(String address);
154
155 /**
156 * Creates and publishes an endpoint for the specified implementor
157 * object at the given address.
158 * <p>
159 * The necessary server infrastructure will be created and
160 * configured by the JAX-WS implementation using some default configuration.
161 *
162 * In order to get more control over the server configuration, please
163 * use the javax.xml.ws.Endpoint#create(String,Object) and
164 * javax.xml.ws.Endpoint#publish(Object) method instead.
165 *
166 * @param address A URI specifying the address and transport/protocol
167 * to use. A http: URI must result in the SOAP 1.1/HTTP
168 * binding being used. Implementations may support other
169 * URI schemes.
170 * @param implementor The endpoint implementor.
171 *
172 * @return The newly created endpoint.
173 *
174 **/
175 public static Endpoint publish(String address, Object implementor) {
176 return Provider.provider().createAndPublishEndpoint(address,
177 implementor);
178 }
179
180 /**
181 * Publishes this endpoint at the provided server context.
182 * A server context encapsulates the server infrastructure
183 * and addressing information for a particular transport.
184 * For a call to this method to succeed, the server context
185 * passed as an argument to it must be compatible with the
186 * endpoint's binding.
187 *
188 * @param serverContext An object representing a server
189 * context to be used for publishing the endpoint.
190 *
191 * @throws java.lang.IllegalArgumentException
192 * If the provided server context is not
193 * supported by the implementation or turns
194 * out to be unusable in conjunction with the
195 * endpoint's binding.
196 *
197 * @throws java.lang.IllegalStateException
198 * If the endpoint has been published already or it has been stopped.
199 **/
200 public abstract void publish(Object serverContext);
201
202 /**
203 * Stops publishing this endpoint.
204 *
205 * If the endpoint is not in a published state, this method
206 * has not effect.
207 *
208 **/
209 public abstract void stop();
210
211 /**
212 * Returns true if the endpoint is in the published state.
213 *
214 * @return <code>true</code> if the endpoint is in the published state.
215 **/
216 public abstract boolean isPublished();
217
218 /**
219 * Returns a list of metadata documents for the service.
220 *
221 * @return <code>List<javax.xml.transform.Source></code> A list of metadata documents for the service
222 **/
223 public abstract List<javax.xml.transform.Source> getMetadata();
224
225 /**
226 * Sets the metadata for this endpoint.
227 *
228 * @param metadata A list of XML document sources containing
229 * metadata information for the endpoint (e.g.
230 * WSDL or XML Schema documents)
231 *
232 * @throws java.lang.IllegalStateException If the endpoint
233 * has already been published.
234 **/
235 public abstract void setMetadata(
236 List<javax.xml.transform.Source> metadata);
237
238 /**
239 * Returns the executor for this <code>Endpoint</code>instance.
240 *
241 * The executor is used to dispatch an incoming request to
242 * the implementor object.
243 *
244 * @return The <code>java.util.concurrent.Executor</code> to be
245 * used to dispatch a request.
246 *
247 * @see java.util.concurrent.Executor
248 **/
249 public abstract java.util.concurrent.Executor getExecutor();
250
251 /**
252 * Sets the executor for this <code>Endpoint</code> instance.
253 *
254 * The executor is used to dispatch an incoming request to
255 * the implementor object.
256 *
257 * If this <code>Endpoint</code> is published using the
258 * <code>publish(Object)</code> method and the specified server
259 * context defines its own threading behavior, the executor
260 * may be ignored.
261 *
262 * @param executor The <code>java.util.concurrent.Executor</code>
263 * to be used to dispatch a request.
264 *
265 * @throws SecurityException If the instance does not support
266 * setting an executor for security reasons (e.g. the
267 * necessary permissions are missing).
268 *
269 * @see java.util.concurrent.Executor
270 **/
271 public abstract void setExecutor(
272 java.util.concurrent.Executor executor);
273
274 /**
275 * Returns the property bag for this <code>Endpoint</code> instance.
276 *
277 * @return Map<String,Object> The property bag
278 * associated with this instance.
279 **/
280 public abstract Map<String, Object> getProperties();
281
282 /**
283 * Sets the property bag for this <code>Endpoint</code> instance.
284 *
285 * @param properties The property bag associated with
286 * this instance.
287 **/
288 public abstract void setProperties(Map<String, Object> properties);
289 }
|