org.systinet.wasp.webservice
Class Registry

java.lang.Object
  extended byorg.systinet.wasp.webservice.Registry

public class Registry
extends java.lang.Object

Registry allows runtime publishing and finding of web services. For instance:

 Wasp.startServer("http");
 Registry.publish("/MyService", new MyServiceImpl());

It also allows the simplest way of service lookup with creating dynamic proxy for the service:

 MyService proxy = (MyService)Registry.lookup("http://googoo:6060/MyService/wsdl", MyService.class);

For more complex client lookup see ServiceClient.

Since:
4.5
Component:
Core

Method Summary
static void addListener(ServiceClientListener listener)
          Adds service client listener.
static void addListener(ServiceEndpointListener listener)
          Adds service endpoint listener.
static ServiceEndpoint getServiceEndpoint(java.lang.String path)
          Gets the service endpoint bound to specified path.
static ServiceEndpoint getServiceEndpoint(java.lang.String path, java.lang.String version)
          Gets the service endpoint bound to specified path.
static ServiceEndpoint[] getServiceEndpoints()
          Gets all service endpoints published or deployed to server.
static java.lang.Object lookup(ServiceClient clientConfiguration)
          Deprecated. use ServiceClient.createProxy(java.lang.Class) instead
static java.lang.Object lookup(java.lang.String definitionURL, java.lang.Class iface)
          Performs service lookup and creates dynamic proxy for the web service described by WSDL document at definitionURL when ServiceClient is not needed (for settings of additional parameters or client processing).
static java.lang.Object lookup(java.lang.String definitionURL, java.lang.Class iface, java.lang.String serviceURL, java.util.Map contextData)
          Deprecated. use ServiceClient.create(java.lang.String, java.util.Map) and ServiceClient.createProxy(java.lang.Class) instead
static void publish(ServiceEndpoint serviceEndpoint)
          Publishes and starts the service.
static ServiceEndpoint publish(java.lang.String path, java.lang.Class implementationClass)
          Publishes and starts new service.
static ServiceEndpoint publish(java.lang.String path, java.lang.Object implementationObject)
          Publishes and starts new service.
static void removeListener(ServiceClientListener listener)
          Removes service client listener.
static void removeListener(ServiceEndpointListener listener)
          Removes service endpoint listener.
static void unpublish(ServiceEndpoint serviceEndpoint)
          Removes service endpoint.
static ServiceEndpoint unpublish(java.lang.String path)
          Removes service endpoint.
static ServiceEndpoint unpublish(java.lang.String path, java.lang.String version)
          Removes service endpoint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

publish

public static final void publish(ServiceEndpoint serviceEndpoint)
                          throws PublishException
Publishes and starts the service. Note: If you want to configure your service, do it before publishing:
 ServiceEndpoint endpoint = ServiceEndpoint.create("/HelloWorld", new HelloWorldImpl());
 endpoint.getInterceptors().add(new MyInterceptor(), Interceptors.DIRECTION_INOUT);
 ...
 Registry.publish(endpoint);

Note: You can publish the service simply by calling:

 Registry.publish(ServiceEndpoint.create("/HelloWorld", new HelloWorldImpl()));

Parameters:
serviceEndpoint - service endpoint to be published
Throws:
PublishException - when the service endpoint path already exists

publish

public static final ServiceEndpoint publish(java.lang.String path,
                                            java.lang.Class implementationClass)
                                     throws PublishException
Publishes and starts new service.

Parameters:
path - service path
implementationClass - service implementation class
Throws:
PublishException - when the service endpoint path already exists
See Also:
publish(ServiceEndpoint)

publish

public static final ServiceEndpoint publish(java.lang.String path,
                                            java.lang.Object implementationObject)
                                     throws PublishException
Publishes and starts new service.

Parameters:
path - service path
implementationObject - service implementation
Throws:
PublishException - when the service endpoint path already exists
See Also:
publish(ServiceEndpoint)

unpublish

public static final void unpublish(ServiceEndpoint serviceEndpoint)
                            throws PublishException
Removes service endpoint. Removes also service instance if it was last service endpoint exposing the serviceEndpoint.getServiceInstance() service instance.

Parameters:
serviceEndpoint - service endpoint to be removed
Throws:
PublishException - when service at given endpoint path does not exist

unpublish

public static final ServiceEndpoint unpublish(java.lang.String path)
                                       throws PublishException
Removes service endpoint. Removes also service instance if it was not referenced by other endpoints. The newest endpoint is unbpublished in case there are more endpoint versions published on the same path.

Parameters:
path - endpoint path
Throws:
PublishException - when service at given endpoint path does not exist
See Also:
unpublish(ServiceEndpoint)

unpublish

public static final ServiceEndpoint unpublish(java.lang.String path,
                                              java.lang.String version)
                                       throws PublishException
Removes service endpoint. Removes also service instance if it was not referenced by other endpoints.

Parameters:
path - endpoint path
version - version of the endpoint to unpublish
Throws:
PublishException - when service at given endpoint path does not exist
See Also:
unpublish(ServiceEndpoint), ServiceEndpoint.setVersion(java.lang.String)

lookup

public static final java.lang.Object lookup(ServiceClient clientConfiguration)
                                     throws LookupException
Deprecated. use ServiceClient.createProxy(java.lang.Class) instead

Performs service lookup and creates stub for the web service described by clientConfiguration.

Parameters:
clientConfiguration - client configuration specifying service definition URL and other lookup parameters
Returns:
the stub that implements the interface specified in serviceClientConfiguration
Throws:
LookupException - when error occurs during lookup

lookup

public static final java.lang.Object lookup(java.lang.String definitionURL,
                                            java.lang.Class iface)
                                     throws LookupException
Performs service lookup and creates dynamic proxy for the web service described by WSDL document at definitionURL when ServiceClient is not needed (for settings of additional parameters or client processing).

Parameters:
definitionURL - URL of WSDL document describing the service
iface - service interface
Returns:
client proxy
Throws:
LookupException - when error occurs during lookup

lookup

public static final java.lang.Object lookup(java.lang.String definitionURL,
                                            java.lang.Class iface,
                                            java.lang.String serviceURL,
                                            java.util.Map contextData)
                                     throws LookupException
Deprecated. use ServiceClient.create(java.lang.String, java.util.Map) and ServiceClient.createProxy(java.lang.Class) instead

Performs service lookup and creates stub for the web service described by WSDL document at definitionURL and hosted at serviceURL (overriding service URL from WSDL document). There can be also specified additional context data that is put into the ServiceClientContext which is created during the lookup operation.

Parameters:
definitionURL - URL of WSDL document describing the service
iface - service interface
serviceURL - URL of service - if the value is not null then it specifies preferred service URL from WSDL document and if no service with such URL exists, then it overrides the URL of the most suitable service from WSDL document (choosen by the other criteria)
contextData - null or data used to configure the lookup operation and stub
Returns:
client stub
Throws:
LookupException - when error occurs during lookup
See Also:
ServiceClientContext

getServiceEndpoints

public static final ServiceEndpoint[] getServiceEndpoints()
Gets all service endpoints published or deployed to server.

Returns:
an array of service endpoints

getServiceEndpoint

public static final ServiceEndpoint getServiceEndpoint(java.lang.String path)
Gets the service endpoint bound to specified path. The newest endpoint is returned in case there are more endpoint versions published on the same path.

Parameters:
path - endpoint path
Returns:
the service endpoint

getServiceEndpoint

public static final ServiceEndpoint getServiceEndpoint(java.lang.String path,
                                                       java.lang.String version)
Gets the service endpoint bound to specified path. Returns null in case there are only endpoints with different versions published.

Parameters:
path - endpoint path
version - the required version
Returns:
the service endpoint
See Also:
ServiceEndpoint.setVersion(java.lang.String)

addListener

public static final void addListener(ServiceEndpointListener listener)
Adds service endpoint listener.

Parameters:
listener - listener to add

removeListener

public static final void removeListener(ServiceEndpointListener listener)
Removes service endpoint listener.

Parameters:
listener - listenr to remove

addListener

public static final void addListener(ServiceClientListener listener)
Adds service client listener.

Parameters:
listener - listener to add

removeListener

public static final void removeListener(ServiceClientListener listener)
Removes service client listener.

Parameters:
listener - listener to remove