Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/ws/Endpoint.java
38890 views
/*1* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.ws;2627import java.util.List;28import java.util.Map;29import javax.xml.ws.spi.Provider;30import javax.xml.ws.spi.http.HttpContext;31import javax.xml.ws.wsaddressing.W3CEndpointReference;32import org.w3c.dom.Element;333435/**36* A Web service endpoint.37*38* <p>Endpoints are created using the static methods defined in this39* class. An endpoint is always tied to one <code>Binding</code>40* and one implementor, both set at endpoint creation time.41*42* <p>An endpoint is either in a published or an unpublished state.43* The <code>publish</code> methods can be used to start publishing44* an endpoint, at which point it starts accepting incoming requests.45* Conversely, the <code>stop</code> method can be used to stop46* accepting incoming requests and take the endpoint down.47* Once stopped, an endpoint cannot be published again.48*49* <p>An <code>Executor</code> may be set on the endpoint in order50* to gain better control over the threads used to dispatch incoming51* requests. For instance, thread pooling with certain parameters52* can be enabled by creating a <code>ThreadPoolExecutor</code> and53* registering it with the endpoint.54*55* <p>Handler chains can be set using the contained <code>Binding</code>.56*57* <p>An endpoint may have a list of metadata documents, such as WSDL58* and XMLSchema documents, bound to it. At publishing time, the59* JAX-WS implementation will try to reuse as much of that metadata60* as possible instead of generating new ones based on the annotations61* present on the implementor.62*63* @since JAX-WS 2.064*65* @see javax.xml.ws.Binding66* @see javax.xml.ws.BindingType67* @see javax.xml.ws.soap.SOAPBinding68* @see java.util.concurrent.Executor69*70**/71public abstract class Endpoint {7273/** Standard property: name of WSDL service.74* <p>Type: javax.xml.namespace.QName75**/76public static final String WSDL_SERVICE = "javax.xml.ws.wsdl.service";7778/** Standard property: name of WSDL port.79* <p>Type: javax.xml.namespace.QName80**/81public static final String WSDL_PORT = "javax.xml.ws.wsdl.port";828384/**85* Creates an endpoint with the specified implementor object. If there is86* a binding specified via a BindingType annotation then it MUST be used else87* a default of SOAP 1.1 / HTTP binding MUST be used.88* <p>89* The newly created endpoint may be published by calling90* one of the {@link javax.xml.ws.Endpoint#publish(String)} and91* {@link javax.xml.ws.Endpoint#publish(Object)} methods.92*93*94* @param implementor The endpoint implementor.95*96* @return The newly created endpoint.97*98**/99public static Endpoint create(Object implementor) {100return create(null, implementor);101}102103/**104* Creates an endpoint with the specified implementor object and web105* service features. If there is a binding specified via a BindingType106* annotation then it MUST be used else a default of SOAP 1.1 / HTTP107* binding MUST be used.108* <p>109* The newly created endpoint may be published by calling110* one of the {@link javax.xml.ws.Endpoint#publish(String)} and111* {@link javax.xml.ws.Endpoint#publish(Object)} methods.112*113*114* @param implementor The endpoint implementor.115* @param features A list of WebServiceFeature to configure on the116* endpoint. Supported features not in the <code>features117* </code> parameter will have their default values.118*119*120* @return The newly created endpoint.121* @since JAX-WS 2.2122*123*/124public static Endpoint create(Object implementor, WebServiceFeature ... features) {125return create(null, implementor, features);126}127128/**129* Creates an endpoint with the specified binding type and130* implementor object.131* <p>132* The newly created endpoint may be published by calling133* one of the {@link javax.xml.ws.Endpoint#publish(String)} and134* {@link javax.xml.ws.Endpoint#publish(Object)} methods.135*136* @param bindingId A URI specifying the binding to use. If the bindingID is137* <code>null</code> and no binding is specified via a BindingType138* annotation then a default SOAP 1.1 / HTTP binding MUST be used.139*140* @param implementor The endpoint implementor.141*142* @return The newly created endpoint.143*144**/145public static Endpoint create(String bindingId, Object implementor) {146return Provider.provider().createEndpoint(bindingId, implementor);147}148149/**150* Creates an endpoint with the specified binding type,151* implementor object, and web service features.152* <p>153* The newly created endpoint may be published by calling154* one of the {@link javax.xml.ws.Endpoint#publish(String)} and155* {@link javax.xml.ws.Endpoint#publish(Object)} methods.156*157* @param bindingId A URI specifying the binding to use. If the bindingID is158* <code>null</code> and no binding is specified via a BindingType159* annotation then a default SOAP 1.1 / HTTP binding MUST be used.160*161* @param implementor The endpoint implementor.162*163* @param features A list of WebServiceFeature to configure on the164* endpoint. Supported features not in the <code>features165* </code> parameter will have their default values.166*167* @return The newly created endpoint.168* @since JAX-WS 2.2169*/170public static Endpoint create(String bindingId, Object implementor, WebServiceFeature ... features) {171return Provider.provider().createEndpoint(bindingId, implementor, features);172}173174/**175* Returns the binding for this endpoint.176*177* @return The binding for this endpoint178**/179public abstract Binding getBinding();180181/**182* Returns the implementation object for this endpoint.183*184* @return The implementor for this endpoint185**/186public abstract Object getImplementor();187188/**189* Publishes this endpoint at the given address.190* The necessary server infrastructure will be created and191* configured by the JAX-WS implementation using some default configuration.192* In order to get more control over the server configuration, please193* use the {@link javax.xml.ws.Endpoint#publish(Object)} method instead.194*195* @param address A URI specifying the address to use. The address196* MUST be compatible with the binding specified at the197* time the endpoint was created.198*199* @throws java.lang.IllegalArgumentException200* If the provided address URI is not usable201* in conjunction with the endpoint's binding.202*203* @throws java.lang.IllegalStateException204* If the endpoint has been published already or it has been stopped.205*206* @throws java.lang.SecurityException207* If a <code>java.lang.SecurityManger</code>208* is being used and the application doesn't have the209* <code>WebServicePermission("publishEndpoint")</code> permission.210**/211public abstract void publish(String address);212213/**214* Creates and publishes an endpoint for the specified implementor215* object at the given address.216* <p>217* The necessary server infrastructure will be created and218* configured by the JAX-WS implementation using some default configuration.219*220* In order to get more control over the server configuration, please221* use the {@link javax.xml.ws.Endpoint#create(String,Object)} and222* {@link javax.xml.ws.Endpoint#publish(Object)} methods instead.223*224* @param address A URI specifying the address and transport/protocol225* to use. A http: URI MUST result in the SOAP 1.1/HTTP226* binding being used. Implementations may support other227* URI schemes.228* @param implementor The endpoint implementor.229*230* @return The newly created endpoint.231*232* @throws java.lang.SecurityException233* If a <code>java.lang.SecurityManger</code>234* is being used and the application doesn't have the235* <code>WebServicePermission("publishEndpoint")</code> permission.236*237**/238public static Endpoint publish(String address, Object implementor) {239return Provider.provider().createAndPublishEndpoint(address, implementor);240}241242/**243* Creates and publishes an endpoint for the specified implementor244* object at the given address. The created endpoint is configured245* with the web service features.246* <p>247* The necessary server infrastructure will be created and248* configured by the JAX-WS implementation using some default configuration.249*250* In order to get more control over the server configuration, please251* use the {@link javax.xml.ws.Endpoint#create(String,Object)} and252* {@link javax.xml.ws.Endpoint#publish(Object)} methods instead.253*254* @param address A URI specifying the address and transport/protocol255* to use. A http: URI MUST result in the SOAP 1.1/HTTP256* binding being used. Implementations may support other257* URI schemes.258* @param implementor The endpoint implementor.259* @param features A list of WebServiceFeature to configure on the260* endpoint. Supported features not in the <code>features261* </code> parameter will have their default values.262* @return The newly created endpoint.263*264* @throws java.lang.SecurityException265* If a <code>java.lang.SecurityManger</code>266* is being used and the application doesn't have the267* <code>WebServicePermission("publishEndpoint")</code> permission.268* @since JAX-WS 2.2269*/270public static Endpoint publish(String address, Object implementor, WebServiceFeature ... features) {271return Provider.provider().createAndPublishEndpoint(address, implementor, features);272}273274275/**276* Publishes this endpoint at the provided server context.277* A server context encapsulates the server infrastructure278* and addressing information for a particular transport.279* For a call to this method to succeed, the server context280* passed as an argument to it MUST be compatible with the281* endpoint's binding.282*283* @param serverContext An object representing a server284* context to be used for publishing the endpoint.285*286* @throws java.lang.IllegalArgumentException287* If the provided server context is not288* supported by the implementation or turns289* out to be unusable in conjunction with the290* endpoint's binding.291*292* @throws java.lang.IllegalStateException293* If the endpoint has been published already or it has been stopped.294*295* @throws java.lang.SecurityException296* If a <code>java.lang.SecurityManger</code>297* is being used and the application doesn't have the298* <code>WebServicePermission("publishEndpoint")</code> permission.299**/300public abstract void publish(Object serverContext);301302/**303* Publishes this endpoint at the provided server context.304* A server context encapsulates the server infrastructure305* and addressing information for a particular transport.306* For a call to this method to succeed, the server context307* passed as an argument to it MUST be compatible with the308* endpoint's binding.309*310* <p>311* This is meant for container developers to publish the312* the endpoints portably and not intended for the end313* developers.314*315*316* @param serverContext An object representing a server317* context to be used for publishing the endpoint.318*319* @throws java.lang.IllegalArgumentException320* If the provided server context is not321* supported by the implementation or turns322* out to be unusable in conjunction with the323* endpoint's binding.324*325* @throws java.lang.IllegalStateException326* If the endpoint has been published already or it has been stopped.327*328* @throws java.lang.SecurityException329* If a <code>java.lang.SecurityManger</code>330* is being used and the application doesn't have the331* <code>WebServicePermission("publishEndpoint")</code> permission.332* @since JAX-WS 2.2333*/334public void publish(HttpContext serverContext) {335throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");336}337338/**339* Stops publishing this endpoint.340*341* If the endpoint is not in a published state, this method342* has no effect.343*344**/345public abstract void stop();346347/**348* Returns true if the endpoint is in the published state.349*350* @return <code>true</code> if the endpoint is in the published state.351**/352public abstract boolean isPublished();353354/**355* Returns a list of metadata documents for the service.356*357* @return <code>List<javax.xml.transform.Source></code> A list of metadata documents for the service358**/359public abstract List<javax.xml.transform.Source> getMetadata();360361/**362* Sets the metadata for this endpoint.363*364* @param metadata A list of XML document sources containing365* metadata information for the endpoint (e.g.366* WSDL or XML Schema documents)367*368* @throws java.lang.IllegalStateException If the endpoint369* has already been published.370**/371public abstract void setMetadata(List<javax.xml.transform.Source> metadata);372373/**374* Returns the executor for this <code>Endpoint</code>instance.375*376* The executor is used to dispatch an incoming request to377* the implementor object.378*379* @return The <code>java.util.concurrent.Executor</code> to be380* used to dispatch a request.381*382* @see java.util.concurrent.Executor383**/384public abstract java.util.concurrent.Executor getExecutor();385386/**387* Sets the executor for this <code>Endpoint</code> instance.388*389* The executor is used to dispatch an incoming request to390* the implementor object.391*392* If this <code>Endpoint</code> is published using the393* <code>publish(Object)</code> method and the specified server394* context defines its own threading behavior, the executor395* may be ignored.396*397* @param executor The <code>java.util.concurrent.Executor</code>398* to be used to dispatch a request.399*400* @throws SecurityException If the instance does not support401* setting an executor for security reasons (e.g. the402* necessary permissions are missing).403*404* @see java.util.concurrent.Executor405**/406public abstract void setExecutor(java.util.concurrent.Executor executor);407408409/**410* Returns the property bag for this <code>Endpoint</code> instance.411*412* @return Map<String,Object> The property bag413* associated with this instance.414**/415public abstract Map<String,Object> getProperties();416417/**418* Sets the property bag for this <code>Endpoint</code> instance.419*420* @param properties The property bag associated with421* this instance.422**/423public abstract void setProperties(Map<String,Object> properties);424425/**426* Returns the <code>EndpointReference</code> associated with427* this <code>Endpoint</code> instance.428* <p>429* If the Binding for this <code>bindingProvider</code> is430* either SOAP1.1/HTTP or SOAP1.2/HTTP, then a431* <code>W3CEndpointReference</code> MUST be returned.432*433* @param referenceParameters Reference parameters to be associated with the434* returned <code>EndpointReference</code> instance.435* @return EndpointReference of this <code>Endpoint</code> instance.436* If the returned <code>EndpointReference</code> is of type437* <code>W3CEndpointReference</code> then it MUST contain the438* the specified <code>referenceParameters</code>.439440* @throws WebServiceException If any error in the creation of441* the <code>EndpointReference</code> or if the <code>Endpoint</code> is442* not in the published state.443* @throws UnsupportedOperationException If this <code>BindingProvider</code>444* uses the XML/HTTP binding.445*446* @see W3CEndpointReference447*448* @since JAX-WS 2.1449**/450public abstract EndpointReference getEndpointReference(Element... referenceParameters);451452453/**454* Returns the <code>EndpointReference</code> associated with455* this <code>Endpoint</code> instance.456*457* @param clazz Specifies the type of EndpointReference that MUST be returned.458* @param referenceParameters Reference parameters to be associated with the459* returned <code>EndpointReference</code> instance.460* @return EndpointReference of type <code>clazz</code> of this461* <code>Endpoint</code> instance.462* If the returned <code>EndpointReference</code> is of type463* <code>W3CEndpointReference</code> then it MUST contain the464* the specified <code>referenceParameters</code>.465466* @throws WebServiceException If any error in the creation of467* the <code>EndpointReference</code> or if the <code>Endpoint</code> is468* not in the published state or if the <code>clazz</code> is not a supported469* <code>EndpointReference</code> type.470* @throws UnsupportedOperationException If this <code>BindingProvider</code>471* uses the XML/HTTP binding.472*473*474* @since JAX-WS 2.1475**/476public abstract <T extends EndpointReference> T getEndpointReference(Class<T> clazz,477Element... referenceParameters);478479/**480* By settng a <code>EndpointContext</code>, JAX-WS runtime knows about481* addresses of other endpoints in an application. If multiple endpoints482* share different ports of a WSDL, then the multiple port addresses483* are patched when the WSDL is accessed.484*485* <p>486* This needs to be set before publishing the endpoints.487*488* @param ctxt that is shared for multiple endpoints489* @throws java.lang.IllegalStateException490* If the endpoint has been published already or it has been stopped.491*492* @since JAX-WS 2.2493*/494public void setEndpointContext(EndpointContext ctxt) {495throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");496}497}498499500