javax.xml.ws.Endpoint Maven / Gradle / Ivy
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005-2011 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.xml.ws;
import java.util.List;
import java.util.Map;
import javax.xml.ws.spi.Provider;
import javax.xml.ws.spi.http.HttpContext;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.w3c.dom.Element;
/**
* A Web service endpoint.
*
* Endpoints are created using the static methods defined in this
* class. An endpoint is always tied to one Binding
* and one implementor, both set at endpoint creation time.
*
*
An endpoint is either in a published or an unpublished state.
* The publish
methods can be used to start publishing
* an endpoint, at which point it starts accepting incoming requests.
* Conversely, the stop
method can be used to stop
* accepting incoming requests and take the endpoint down.
* Once stopped, an endpoint cannot be published again.
*
*
An Executor
may be set on the endpoint in order
* to gain better control over the threads used to dispatch incoming
* requests. For instance, thread pooling with certain parameters
* can be enabled by creating a ThreadPoolExecutor
and
* registering it with the endpoint.
*
*
Handler chains can be set using the contained Binding
.
*
*
An endpoint may have a list of metadata documents, such as WSDL
* and XMLSchema documents, bound to it. At publishing time, the
* JAX-WS implementation will try to reuse as much of that metadata
* as possible instead of generating new ones based on the annotations
* present on the implementor.
*
* @since JAX-WS 2.0
*
* @see javax.xml.ws.Binding
* @see javax.xml.ws.BindingType
* @see javax.xml.ws.soap.SOAPBinding
* @see java.util.concurrent.Executor
*
**/
public abstract class Endpoint {
/** Standard property: name of WSDL service.
*
Type: javax.xml.namespace.QName
**/
public static final String WSDL_SERVICE = "javax.xml.ws.wsdl.service";
/** Standard property: name of WSDL port.
*
Type: javax.xml.namespace.QName
**/
public static final String WSDL_PORT = "javax.xml.ws.wsdl.port";
/**
* Creates an endpoint with the specified implementor object. If there is
* a binding specified via a BindingType annotation then it MUST be used else
* a default of SOAP 1.1 / HTTP binding MUST be used.
*
* The newly created endpoint may be published by calling
* one of the {@link javax.xml.ws.Endpoint#publish(String)} and
* {@link javax.xml.ws.Endpoint#publish(Object)} methods.
*
*
* @param implementor The endpoint implementor.
*
* @return The newly created endpoint.
*
**/
public static Endpoint create(Object implementor) {
return create(null, implementor);
}
/**
* Creates an endpoint with the specified implementor object and web
* service features. If there is a binding specified via a BindingType
* annotation then it MUST be used else a default of SOAP 1.1 / HTTP
* binding MUST be used.
*
* The newly created endpoint may be published by calling
* one of the {@link javax.xml.ws.Endpoint#publish(String)} and
* {@link javax.xml.ws.Endpoint#publish(Object)} methods.
*
*
* @param implementor The endpoint implementor.
* @param features A list of WebServiceFeature to configure on the
* endpoint. Supported features not in the features
*
parameter will have their default values.
*
*
* @return The newly created endpoint.
* @since JAX-WS 2.2
*
*/
public static Endpoint create(Object implementor, WebServiceFeature ... features) {
return create(null, implementor, features);
}
/**
* Creates an endpoint with the specified binding type and
* implementor object.
*
* The newly created endpoint may be published by calling
* one of the {@link javax.xml.ws.Endpoint#publish(String)} and
* {@link javax.xml.ws.Endpoint#publish(Object)} methods.
*
* @param bindingId A URI specifying the binding to use. If the bindingID is
* null
and no binding is specified via a BindingType
* annotation then a default SOAP 1.1 / HTTP binding MUST be used.
*
* @param implementor The endpoint implementor.
*
* @return The newly created endpoint.
*
**/
public static Endpoint create(String bindingId, Object implementor) {
return Provider.provider().createEndpoint(bindingId, implementor);
}
/**
* Creates an endpoint with the specified binding type,
* implementor object, and web service features.
*
* The newly created endpoint may be published by calling
* one of the {@link javax.xml.ws.Endpoint#publish(String)} and
* {@link javax.xml.ws.Endpoint#publish(Object)} methods.
*
* @param bindingId A URI specifying the binding to use. If the bindingID is
* null
and no binding is specified via a BindingType
* annotation then a default SOAP 1.1 / HTTP binding MUST be used.
*
* @param implementor The endpoint implementor.
*
* @param features A list of WebServiceFeature to configure on the
* endpoint. Supported features not in the features
*
parameter will have their default values.
*
* @return The newly created endpoint.
* @since JAX-WS 2.2
*/
public static Endpoint create(String bindingId, Object implementor, WebServiceFeature ... features) {
return Provider.provider().createEndpoint(bindingId, implementor, features);
}
/**
* Returns the binding for this endpoint.
*
* @return The binding for this endpoint
**/
public abstract Binding getBinding();
/**
* Returns the implementation object for this endpoint.
*
* @return The implementor for this endpoint
**/
public abstract Object getImplementor();
/**
* Publishes this endpoint at the given address.
* The necessary server infrastructure will be created and
* configured by the JAX-WS implementation using some default configuration.
* In order to get more control over the server configuration, please
* use the {@link javax.xml.ws.Endpoint#publish(Object)} method instead.
*
* @param address A URI specifying the address to use. The address
* MUST be compatible with the binding specified at the
* time the endpoint was created.
*
* @throws java.lang.IllegalArgumentException
* If the provided address URI is not usable
* in conjunction with the endpoint's binding.
*
* @throws java.lang.IllegalStateException
* If the endpoint has been published already or it has been stopped.
*
* @throws java.lang.SecurityException
* If a java.lang.SecurityManger
* is being used and the application doesn't have the
* WebServicePermission("publishEndpoint")
permission.
**/
public abstract void publish(String address);
/**
* Creates and publishes an endpoint for the specified implementor
* object at the given address.
*
* The necessary server infrastructure will be created and
* configured by the JAX-WS implementation using some default configuration.
*
* In order to get more control over the server configuration, please
* use the {@link javax.xml.ws.Endpoint#create(String,Object)} and
* {@link javax.xml.ws.Endpoint#publish(Object)} methods instead.
*
* @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 The endpoint implementor.
*
* @return The newly created endpoint.
*
* @throws java.lang.SecurityException
* If a java.lang.SecurityManger
* is being used and the application doesn't have the
* WebServicePermission("publishEndpoint")
permission.
*
**/
public static Endpoint publish(String address, Object implementor) {
return Provider.provider().createAndPublishEndpoint(address, implementor);
}
/**
* Creates and publishes an endpoint for the specified implementor
* object at the given address. The created endpoint is configured
* with the web service features.
*
* The necessary server infrastructure will be created and
* configured by the JAX-WS implementation using some default configuration.
*
* In order to get more control over the server configuration, please
* use the {@link javax.xml.ws.Endpoint#create(String,Object)} and
* {@link javax.xml.ws.Endpoint#publish(Object)} methods instead.
*
* @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 The endpoint implementor.
* @param features A list of WebServiceFeature to configure on the
* endpoint. Supported features not in the features
*
parameter will have their default values.
* @return The newly created endpoint.
*
* @throws java.lang.SecurityException
* If a java.lang.SecurityManger
* is being used and the application doesn't have the
* WebServicePermission("publishEndpoint")
permission.
* @since JAX-WS 2.2
*/
public static Endpoint publish(String address, Object implementor, WebServiceFeature ... features) {
return Provider.provider().createAndPublishEndpoint(address, implementor, features);
}
/**
* Publishes this endpoint at the provided server context.
* A server context encapsulates the server infrastructure
* and addressing information for a particular transport.
* For a call to this method to succeed, the server context
* passed as an argument to it MUST be compatible with the
* endpoint's binding.
*
* @param serverContext An object representing a server
* context to be used for publishing the endpoint.
*
* @throws java.lang.IllegalArgumentException
* If the provided server context is not
* supported by the implementation or turns
* out to be unusable in conjunction with the
* endpoint's binding.
*
* @throws java.lang.IllegalStateException
* If the endpoint has been published already or it has been stopped.
*
* @throws java.lang.SecurityException
* If a java.lang.SecurityManger
* is being used and the application doesn't have the
* WebServicePermission("publishEndpoint")
permission.
**/
public abstract void publish(Object serverContext);
/**
* Publishes this endpoint at the provided server context.
* A server context encapsulates the server infrastructure
* and addressing information for a particular transport.
* For a call to this method to succeed, the server context
* passed as an argument to it MUST be compatible with the
* endpoint's binding.
*
*
* This is meant for container developers to publish the
* the endpoints portably and not intended for the end
* developers.
*
*
* @param serverContext An object representing a server
* context to be used for publishing the endpoint.
*
* @throws java.lang.IllegalArgumentException
* If the provided server context is not
* supported by the implementation or turns
* out to be unusable in conjunction with the
* endpoint's binding.
*
* @throws java.lang.IllegalStateException
* If the endpoint has been published already or it has been stopped.
*
* @throws java.lang.SecurityException
* If a java.lang.SecurityManger
* is being used and the application doesn't have the
* WebServicePermission("publishEndpoint")
permission.
* @since JAX-WS 2.2
*/
public void publish(HttpContext serverContext) {
throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
}
/**
* Stops publishing this endpoint.
*
* If the endpoint is not in a published state, this method
* has no effect.
*
**/
public abstract void stop();
/**
* Returns true if the endpoint is in the published state.
*
* @return true
if the endpoint is in the published state.
**/
public abstract boolean isPublished();
/**
* Returns a list of metadata documents for the service.
*
* @return List<javax.xml.transform.Source>
A list of metadata documents for the service
**/
public abstract List getMetadata();
/**
* Sets the metadata for this endpoint.
*
* @param metadata A list of XML document sources containing
* metadata information for the endpoint (e.g.
* WSDL or XML Schema documents)
*
* @throws java.lang.IllegalStateException If the endpoint
* has already been published.
**/
public abstract void setMetadata(List metadata);
/**
* Returns the executor for this Endpoint
instance.
*
* The executor is used to dispatch an incoming request to
* the implementor object.
*
* @return The java.util.concurrent.Executor
to be
* used to dispatch a request.
*
* @see java.util.concurrent.Executor
**/
public abstract java.util.concurrent.Executor getExecutor();
/**
* Sets the executor for this Endpoint
instance.
*
* The executor is used to dispatch an incoming request to
* the implementor object.
*
* If this Endpoint
is published using the
* publish(Object)
method and the specified server
* context defines its own threading behavior, the executor
* may be ignored.
*
* @param executor The java.util.concurrent.Executor
* to be used to dispatch a request.
*
* @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);
/**
* Returns the property bag for this Endpoint
instance.
*
* @return Map<String,Object> The property bag
* associated with this instance.
**/
public abstract Map getProperties();
/**
* Sets the property bag for this Endpoint
instance.
*
* @param properties The property bag associated with
* this instance.
**/
public abstract void setProperties(Map properties);
/**
* Returns the EndpointReference
associated with
* this Endpoint
instance.
*
* If the Binding for this bindingProvider
is
* either SOAP1.1/HTTP or SOAP1.2/HTTP, then a
* W3CEndpointReference
MUST be returned.
*
* @param referenceParameters Reference parameters to be associated with the
* returned EndpointReference
instance.
* @return EndpointReference of this Endpoint
instance.
* If the returned EndpointReference
is of type
* W3CEndpointReference
then it MUST contain the
* the specified referenceParameters
.
* @throws WebServiceException If any error in the creation of
* the EndpointReference
or if the Endpoint
is
* not in the published state.
* @throws UnsupportedOperationException If this BindingProvider
* uses the XML/HTTP binding.
*
* @see W3CEndpointReference
*
* @since JAX-WS 2.1
**/
public abstract EndpointReference getEndpointReference(Element... referenceParameters);
/**
* Returns the EndpointReference
associated with
* this Endpoint
instance.
*
* @param clazz Specifies the type of EndpointReference that MUST be returned.
* @param referenceParameters Reference parameters to be associated with the
* returned EndpointReference
instance.
* @return EndpointReference of type clazz
of this
* Endpoint
instance.
* If the returned EndpointReference
is of type
* W3CEndpointReference
then it MUST contain the
* the specified referenceParameters
.
* @throws WebServiceException If any error in the creation of
* the EndpointReference
or if the Endpoint
is
* not in the published state or if the clazz
is not a supported
* EndpointReference
type.
* @throws UnsupportedOperationException If this BindingProvider
* uses the XML/HTTP binding.
*
*
* @since JAX-WS 2.1
**/
public abstract T getEndpointReference(Class clazz,
Element... referenceParameters);
/**
* By settng a EndpointContext
, JAX-WS runtime knows about
* addresses of other endpoints in an application. If multiple endpoints
* share different ports of a WSDL, then the multiple port addresses
* are patched when the WSDL is accessed.
*
*
* This needs to be set before publishing the endpoints.
*
* @param ctxt that is shared for multiple endpoints
* @throws java.lang.IllegalStateException
* If the endpoint has been published already or it has been stopped.
*
* @since JAX-WS 2.2
*/
public void setEndpointContext(EndpointContext ctxt) {
throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
}
}