org.systinet.wasp.webservice
Class ServiceEndpoint

java.lang.Object
  extended byorg.systinet.wasp.webservice.ServiceEndpoint
All Implemented Interfaces:
Processing

public abstract class ServiceEndpoint
extends java.lang.Object
implements Processing

ServiceEndpoint represents one webservice endpoint. Using this class, one can fully setup various endpoint properties and processors affecting message processing such as handlers, interceptors etc. Common usage is as following:

 ServiceEndpoint service = ServiceEndpoint.create("/HelloWorld", new HelloService());
 service.set...;
 ...
 Registry.publish(service);

Since:
4.5
Component:
Core

Field Summary
static int TYPE_JAVA
          Java type of webservice.
static int TYPE_RAW
          Raw type of webservice.
static int TYPE_XML
          XML type of webservice.
static java.lang.String XML_PROTOCOL_SOAP11
          Deprecated. See setXMLProtocol(java.lang.String).
static java.lang.String XML_PROTOCOL_SOAP12
          Deprecated. See setXMLProtocol(java.lang.String).
 
Constructor Summary
protected ServiceEndpoint()
           
 
Method Summary
abstract  void addListener(ServiceEndpointListener listener)
          Adds listener to this service endpoint.
static ServiceEndpoint create(java.lang.String path, java.lang.Class implementationClass)
          Creates new instance of ServiceEndpoint.
static ServiceEndpoint create(java.lang.String path, java.lang.Class implementationClass, java.lang.Class iface)
          Creates new instance of ServiceEndpoint.
static ServiceEndpoint create(java.lang.String path, java.lang.Object implementationObject)
          Creates new instance of ServiceEndpoint.
static ServiceEndpoint create(java.lang.String path, java.lang.Object implementationObject, java.lang.Class iface)
          Creates new instance of ServiceEndpoint.
static ServiceEndpoint create(java.lang.String path, ServiceEndpoint serviceEndpoint)
          Creates new instance of ServiceEndpoint based on supplied serviceEndpoint.
static ServiceEndpoint create(java.lang.String path, ServiceEndpoint serviceEndpoint, java.lang.Class iface)
          Creates new instance of ServiceEndpoint based on supplied serviceEndpoint.
static ServiceEndpoint create(java.lang.String path, ServiceInstance serviceInstance)
          Creates new instance of ServiceEndpoint.
static ServiceEndpoint create(java.lang.String path, ServiceInstance serviceInstance, java.lang.Class iface)
          Creates new instance of ServiceEndpoint.
abstract  Attributes getAttributes()
          Retrieves attributes store bound to this service endpoint.
abstract  Configurable getConfigurable()
          Returns the custom configuration of the service endpoint.
abstract  ServiceEndpointContext getContext()
          Retrieves unique context bound to this service endpoint.
abstract  java.lang.Class getInterface()
          Retrieves endpoint iface if set.
abstract  java.lang.String getPath()
          Retrieves server path of this endpoint.
abstract  ServiceInstance getServiceInstance()
          Retrieves service instance bound to this endpoint.
abstract  int getServiceType()
          Retrieves type of this service endpoint based on implementation interface.
abstract  java.lang.String getServiceURL()
          Returns the value for overriding the soap:address location attribute in returned WSDL or null if not set (and WSO2 SOA Enablement Server autodetects the proper value).
abstract  java.lang.String getVersion()
          Returns the version of this endpoint.
abstract  Definition getWSDL()
          Retrieves WSDL definition for this service endpoint (either set by calling setWSDL(javax.wsdl.Definition) or generated upon publishing) or null, if this service endpoint was not published yet and no WSDL was set by user.
abstract  java.lang.String getWSDLPortName()
          Returns the name of service port in the WSDL definition.
abstract  QName getWSDLServiceName()
          Returns name of selected service in the WSDL definition (see also setWSDLServiceName(javax.xml.namespace.QName).
abstract  java.lang.String getXMLProtocol()
          Deprecated. This methods returns XML protocol set by setXMLProtocol(java.lang.String). Inside any XML processing unit (e.g. JAX-RPC handler) you can get version of used XML protocol from CallContext (see CallContext.XML_PROTOCOL).
abstract  void removeListener(ServiceEndpointListener listener)
          Removes listener form this service endpoint.
abstract  void setConfigurable(Configurable configurable)
          Sets the custom configuration of the service service endpoint.
abstract  void setInterface(java.lang.Class iface)
          Sets iface.
abstract  void setPath(java.lang.String path)
          Sets the service endpoint server path.
abstract  void setServiceURL(java.lang.String url)
          Sets the soap:address location attribute in returned WSDL.
abstract  void setVersion(java.lang.String version)
          Sets the version of this endpoint.
abstract  void setWSDL(Definition wsdl)
          Sets WSDL definition for this service endpoint.
abstract  void setWSDLPortName(java.lang.String portName)
          Sets the name of service port in WSDL definition.
abstract  void setWSDLServiceName(QName serviceName)
          Sets name of service in the WSDL definition.
abstract  void setXMLProtocol(java.lang.String protocol)
          Deprecated. XML protocol of the service is determined by WSDL. Use Java2WSDL and Java2WSDL.setProtocol to generate WSDL for required XML protocol and set this WSDL to this ServiceEndpoint with setWSDL(javax.wsdl.Definition).

You can set XML protocol for the service with this code:
 ServiceEndpoint endpoint = ServiceEndpoint.create("/MyEndpoint", new MyService());
 Java2WSDL java2wsdl = Java2WSDLFactory.newJava2WSDL();
 java2wsdl.setProtocol(Java2WSDL.PROTOCOL_SOAP11_SOAP12);
 Definition wsdl = java2wsdl.generateDefinition(MyService.class);
 endpoint.setWSDL(wsdl);
 Registry.publish(endpoint);
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.systinet.wasp.webservice.Processing
getHandlers, getHeaderProcessors, getInterceptors
 

Field Detail

TYPE_JAVA

public static final int TYPE_JAVA
Java type of webservice. This is used by getServiceType(). This type of webservice has instance which can implement arbitrary interface.

See Also:
Constant Field Values

TYPE_XML

public static final int TYPE_XML
XML type of webservice. This is used by getServiceType(). This type of webservice has instance which must implement ReqRespListener or OnewayListener.

See Also:
Constant Field Values

TYPE_RAW

public static final int TYPE_RAW
Raw type of webservice. This is used by getServiceType(). This type of webservice has instance which must implement RawService.

See Also:
Constant Field Values

XML_PROTOCOL_SOAP11

public static final java.lang.String XML_PROTOCOL_SOAP11
Deprecated. See setXMLProtocol(java.lang.String).

SOAP11 as XML protocol. This is used by getXMLProtocol() and setXMLProtocol(java.lang.String).

See Also:
Constant Field Values

XML_PROTOCOL_SOAP12

public static final java.lang.String XML_PROTOCOL_SOAP12
Deprecated. See setXMLProtocol(java.lang.String).

SOAP12 as XML protocol. This is used by getXMLProtocol() and setXMLProtocol(java.lang.String).

See Also:
Constant Field Values
Constructor Detail

ServiceEndpoint

protected ServiceEndpoint()
Method Detail

create

public static ServiceEndpoint create(java.lang.String path,
                                     java.lang.Object implementationObject)
Creates new instance of ServiceEndpoint.

Parameters:
path - server path of created endpoint
implementationObject - implementation of endpoint
Returns:
instance of ServiceEndpoint, ready for publishing
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

create

public static ServiceEndpoint create(java.lang.String path,
                                     java.lang.Class implementationClass)
Creates new instance of ServiceEndpoint.

Parameters:
path - server path of created endpoint
implementationClass - class of endpoint's implementation
Returns:
instance of ServiceEndpoint, ready for publishing
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

create

public static ServiceEndpoint create(java.lang.String path,
                                     java.lang.Object implementationObject,
                                     java.lang.Class iface)
Creates new instance of ServiceEndpoint.

Parameters:
path - server path of created endpoint
implementationObject - implementation of endpoint
iface - specification of methods visible after publishing
Returns:
instance of ServiceEndpoint, ready for publishing
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

create

public static ServiceEndpoint create(java.lang.String path,
                                     java.lang.Class implementationClass,
                                     java.lang.Class iface)
Creates new instance of ServiceEndpoint.

Parameters:
path - server path of created endpoint
implementationClass - class of endpoint's implementation
iface - specification of methods visible after publishing
Returns:
instance of ServiceEndpoint, ready for publishing
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

create

public static ServiceEndpoint create(java.lang.String path,
                                     ServiceInstance serviceInstance)
Creates new instance of ServiceEndpoint.

Parameters:
path - server path of created endpoint
serviceInstance - service instance
Returns:
instance of ServiceEndpoint, ready for publishing
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

create

public static ServiceEndpoint create(java.lang.String path,
                                     ServiceInstance serviceInstance,
                                     java.lang.Class iface)
Creates new instance of ServiceEndpoint.

Parameters:
path - server path of created endpoint
serviceInstance - service instance
iface - specification of methods visible after publishing
Returns:
instance of ServiceEndpoint, ready for publishing
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

create

public static ServiceEndpoint create(java.lang.String path,
                                     ServiceEndpoint serviceEndpoint)
Creates new instance of ServiceEndpoint based on supplied serviceEndpoint.

Parameters:
path - server path of created endpoint
serviceEndpoint - source of settings for newly created endpoint
Returns:
instance of ServiceEndpoint, ready for publishing
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

create

public static ServiceEndpoint create(java.lang.String path,
                                     ServiceEndpoint serviceEndpoint,
                                     java.lang.Class iface)
Creates new instance of ServiceEndpoint based on supplied serviceEndpoint.

Parameters:
path - server path of created endpoint
serviceEndpoint - source of settings for newly created endpoint
iface - specification of methods visible after publishing
Returns:
instance of ServiceEndpoint, ready for publishing
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

getConfigurable

public abstract Configurable getConfigurable()
Returns the custom configuration of the service endpoint.

Returns:
the configuration of the service

setConfigurable

public abstract void setConfigurable(Configurable configurable)
Sets the custom configuration of the service service endpoint.

Parameters:
configurable - the configuration of the service endpoint

getPath

public abstract java.lang.String getPath()
Retrieves server path of this endpoint.

Returns:
server URI

getServiceInstance

public abstract ServiceInstance getServiceInstance()
Retrieves service instance bound to this endpoint.

Returns:
service instance

getInterface

public abstract java.lang.Class getInterface()
Retrieves endpoint iface if set. Otherwise returns null.

Returns:
endpoint iface

getContext

public abstract ServiceEndpointContext getContext()
Retrieves unique context bound to this service endpoint. This context is set after publishing. null is returned before endpoint publishing.

Returns:
service endpoint context
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

getServiceType

public abstract int getServiceType()
Retrieves type of this service endpoint based on implementation interface.

Returns:
type type of service endpoint. Can be either TYPE_JAVA, TYPE_XML or TYPE_RAW.

getWSDL

public abstract Definition getWSDL()
Retrieves WSDL definition for this service endpoint (either set by calling setWSDL(javax.wsdl.Definition) or generated upon publishing) or null, if this service endpoint was not published yet and no WSDL was set by user.

Returns:
WSDL definition

setWSDL

public abstract void setWSDL(Definition wsdl)
                      throws java.lang.IllegalStateException
Sets WSDL definition for this service endpoint. If not set, it is automatically generated during publish process. WSDL definition can be obtained with WSDLReader.readWSDL(java.lang.String), for instance:
 Definition myWSDL = WSDLFactory.newInstance().newWSDLReader().readWSDL(null, "...");

Parameters:
wsdl - WSDL definition.
Throws:
java.lang.IllegalStateException - when this service endpoint is already published.
See Also:
Registry.publish(org.systinet.wasp.webservice.ServiceEndpoint)

getWSDLServiceName

public abstract QName getWSDLServiceName()
Returns name of selected service in the WSDL definition (see also setWSDLServiceName(javax.xml.namespace.QName).

Returns:
name of selected service in WSDL definition
See Also:
setWSDLServiceName(javax.xml.namespace.QName)

setWSDLServiceName

public abstract void setWSDLServiceName(QName serviceName)
                                 throws java.lang.IllegalStateException
Sets name of service in the WSDL definition. It allows to choose one of more services in custom WSDL set by setWSDL(javax.wsdl.Definition).

Parameters:
serviceName - name of service in WSDL definition
Throws:
java.lang.IllegalStateException - when this service endpoint is already published.

getWSDLPortName

public abstract java.lang.String getWSDLPortName()
Returns the name of service port in the WSDL definition. (see also setWSDLPortName(java.lang.String).

Returns:
name of selected service port in the WSDL definition
See Also:
setWSDLPortName(java.lang.String)

setWSDLPortName

public abstract void setWSDLPortName(java.lang.String portName)
                              throws java.lang.IllegalStateException
Sets the name of service port in WSDL definition. It allows to choose one of more ports in custom WSDL set by setWSDL(javax.wsdl.Definition).

Parameters:
portName - name of service port in WSDL definition
Throws:
java.lang.IllegalStateException - when this service endpoint is already published.
See Also:
setWSDL(javax.wsdl.Definition)

getXMLProtocol

public abstract java.lang.String getXMLProtocol()
Deprecated. This methods returns XML protocol set by setXMLProtocol(java.lang.String). Inside any XML processing unit (e.g. JAX-RPC handler) you can get version of used XML protocol from CallContext (see CallContext.XML_PROTOCOL).

Retrieves SOAP protocol this service endpoint is communicating by.

Returns:
either XML_PROTOCOL_SOAP11 or XML_PROTOCOL_SOAP12

setXMLProtocol

public abstract void setXMLProtocol(java.lang.String protocol)
                             throws java.lang.IllegalStateException
Deprecated. XML protocol of the service is determined by WSDL. Use Java2WSDL and Java2WSDL.setProtocol to generate WSDL for required XML protocol and set this WSDL to this ServiceEndpoint with setWSDL(javax.wsdl.Definition).

You can set XML protocol for the service with this code:
 ServiceEndpoint endpoint = ServiceEndpoint.create("/MyEndpoint", new MyService());
 Java2WSDL java2wsdl = Java2WSDLFactory.newJava2WSDL();
 java2wsdl.setProtocol(Java2WSDL.PROTOCOL_SOAP11_SOAP12);
 Definition wsdl = java2wsdl.generateDefinition(MyService.class);
 endpoint.setWSDL(wsdl);
 Registry.publish(endpoint);

Sets SOAP protocol used by this service endpoint. Can be set only before publishing, otherwise exception is thrown.

Parameters:
protocol - either XML_PROTOCOL_SOAP11 or XML_PROTOCOL_SOAP12
Throws:
java.lang.IllegalStateException - when this service endpoint is already published.

setInterface

public abstract void setInterface(java.lang.Class iface)
                           throws java.lang.IllegalStateException
Sets iface.

Parameters:
iface - specification of visible operations
Throws:
java.lang.IllegalStateException - when this service endpoint is already published.

setPath

public abstract void setPath(java.lang.String path)
                      throws java.lang.IllegalStateException
Sets the service endpoint server path.

Parameters:
path - service path
Throws:
java.lang.IllegalStateException - when this service endpoint is already published.

setServiceURL

public abstract void setServiceURL(java.lang.String url)
                            throws java.lang.IllegalStateException
Sets the soap:address location attribute in returned WSDL. Leave unset to let the WSO2 SOA Enablement Server autodetect the service location based on the request (i.e. http://localhost:6060/HelloWorld when look-up performed on localhost or http://mymachine.com:6060/HelloWorld when look-up performed on mymachine.com). Set to override the autodetection in cases such as placing the WSO2 SOA Enablement Server behind the IP forwarding firewall etc.

Parameters:
url - service location URL used in attribute
Throws:
java.lang.IllegalStateException - when this service endpoint is already published.

getServiceURL

public abstract java.lang.String getServiceURL()
Returns the value for overriding the soap:address location attribute in returned WSDL or null if not set (and WSO2 SOA Enablement Server autodetects the proper value).
Note: if this value has not been set in runtime (see setServiceURL(String), but it had been set in the service deployment descriptor, the value from deployment descriptor is returned instead.

Returns:
service location URI overriding the attribute

getAttributes

public abstract Attributes getAttributes()
Retrieves attributes store bound to this service endpoint.

Returns:
attributes store

addListener

public abstract void addListener(ServiceEndpointListener listener)
Adds listener to this service endpoint.

Parameters:
listener - listener to add

removeListener

public abstract void removeListener(ServiceEndpointListener listener)
Removes listener form this service endpoint.

Parameters:
listener - listener to remove

setVersion

public abstract void setVersion(java.lang.String version)
Sets the version of this endpoint. Version is used when publishing more endpoints to the same path; then the processing from endpoint with the largest version number is used. Version contains integer numbers separated by dots. Comparison works so that "2.0.1" > "2.0" and "1.0" == "1.0.0" == "1".

Parameters:
version - the version, default value is "1.0"

getVersion

public abstract java.lang.String getVersion()
Returns the version of this endpoint. Version is used when publishing more endpoints to the same path; then the processing from endpoint with the largest version number is used.

Returns:
the version, default value is "1.0"
See Also:
setVersion(java.lang.String)