org.talend.esb.servicelocator.client
Interface ServiceLocator

All Known Implementing Classes:
ServiceLocatorImpl

public interface ServiceLocator

This is the entry point for clients of the Service Locator. To access the Service Locator clients have to first connect to the Service Locator to get a session assigned. Once the connection is established the client will periodically send heart beats to the server to keep the session alive.

The Service Locator provides the following operations.


Nested Class Summary
static interface ServiceLocator.PostConnectAction
          Callback interface to define actions that must be executed after a successful connect or reconnect.
 
Method Summary
 void connect()
          Establish a connection to the Service Locator.
 void disconnect()
          Disconnects from a Service Locator server.
 SLEndpoint getEndpoint(QName serviceName, String endpoint)
           
 List<String> getEndpointNames(QName serviceName)
          For the given service return all endpoints that currently registered at the Service Locator Service.
 List<SLEndpoint> getEndpoints(QName serviceName)
           
 List<QName> getServices()
          Return all services for which endpoints are registered at the Service Locator Service.
 List<String> lookup(QName serviceName)
          For the given service return all endpoints that currently registered at the Service Locator Service.
 List<String> lookup(QName serviceName, SLPropertiesMatcher matcher)
           
 void register(EndpointProvider eprProvider)
           
 void register(QName serviceName, String endpoint)
          For a given service register the endpoint of a concrete provider of this service.
 void register(QName serviceName, String endpoint, SLProperties properties)
           
 void removeEndpoint(QName serviceName, String endpoint)
           
 void setPostConnectAction(ServiceLocator.PostConnectAction postConnectAction)
           
 void unregister(EndpointProvider epProvider)
           
 void unregister(QName serviceName, String endpoint)
          For a given service unregister a previously registered endpoint.
 

Method Detail

connect

void connect()
             throws InterruptedException,
                    ServiceLocatorException
Establish a connection to the Service Locator. After successful connection the specified ServiceLocator.PostConnectAction is run. If the session to the server expires because the server could not be reached within the specified time, a reconnect is automatically executed as soon as the server can be reached again. Because after a session time out all registered endpoints are removed it is important to specify a ServiceLocator.PostConnectAction that re-registers all endpoints.

Throws:
InterruptedException - the current Thread was interrupted when waiting for a successful connection to the ServiceLocator
ServiceLocatorException - the connect operation failed

disconnect

void disconnect()
                throws InterruptedException,
                       ServiceLocatorException
Disconnects from a Service Locator server. All endpoints that were registered before are removed from the server. To be able to communicate with a Service Locator server again the client has to connect again.

Throws:
InterruptedException - the current Thread was interrupted when waiting for the disconnect to happen
ServiceLocatorException

register

void register(QName serviceName,
              String endpoint)
              throws ServiceLocatorException,
                     InterruptedException
For a given service register the endpoint of a concrete provider of this service. If the client is destroyed, disconnected, or fails to successfully send the heartbeat for a period of time defined by the session timeout parameter the endpoint is removed from the Service Locator. To ensure that all available endpoints are re-registered when the client reconnects after a session expired a ServiceLocator.PostConnectAction should be set that registers all endpoints.

Parameters:
serviceName - the name of the service the endpoint is registered for, must not be null
endpoint - the endpoint to register, must not be null
Throws:
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting for a response of the ServiceLocator

register

void register(QName serviceName,
              String endpoint,
              SLProperties properties)
              throws ServiceLocatorException,
                     InterruptedException
Throws:
ServiceLocatorException
InterruptedException

register

void register(EndpointProvider eprProvider)
              throws ServiceLocatorException,
                     InterruptedException
Throws:
ServiceLocatorException
InterruptedException

unregister

void unregister(QName serviceName,
                String endpoint)
                throws ServiceLocatorException,
                       InterruptedException
For a given service unregister a previously registered endpoint.

Parameters:
serviceName - the name of the service the endpoint is unregistered for, must not be null
endpoint - the endpoint to unregister, must not be null
serviceName -
endpoint -
Throws:
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting for a response of the ServiceLocator

unregister

void unregister(EndpointProvider epProvider)
                throws ServiceLocatorException,
                       InterruptedException
Throws:
ServiceLocatorException
InterruptedException

removeEndpoint

void removeEndpoint(QName serviceName,
                    String endpoint)
                    throws ServiceLocatorException,
                           InterruptedException
Throws:
ServiceLocatorException
InterruptedException

getServices

List<QName> getServices()
                        throws InterruptedException,
                               ServiceLocatorException
Return all services for which endpoints are registered at the Service Locator Service.

Returns:
a possibly empty list of services
Throws:
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting for a response of the ServiceLocator

getEndpoint

SLEndpoint getEndpoint(QName serviceName,
                       String endpoint)
                       throws ServiceLocatorException,
                              InterruptedException
Throws:
ServiceLocatorException
InterruptedException

getEndpoints

List<SLEndpoint> getEndpoints(QName serviceName)
                              throws ServiceLocatorException,
                                     InterruptedException
Throws:
ServiceLocatorException
InterruptedException

getEndpointNames

List<String> getEndpointNames(QName serviceName)
                              throws ServiceLocatorException,
                                     InterruptedException
For the given service return all endpoints that currently registered at the Service Locator Service.

Parameters:
serviceName - the name of the service for which to get the endpoints, must not be null
Returns:
a possibly empty list of endpoints
Throws:
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting for a response of the ServiceLocator

lookup

List<String> lookup(QName serviceName)
                    throws ServiceLocatorException,
                           InterruptedException
For the given service return all endpoints that currently registered at the Service Locator Service.

Parameters:
serviceName - the name of the service for which to get the endpoints, must not be null
Returns:
a possibly empty list of endpoints
Throws:
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting for a response of the ServiceLocator

lookup

List<String> lookup(QName serviceName,
                    SLPropertiesMatcher matcher)
                    throws ServiceLocatorException,
                           InterruptedException
Throws:
ServiceLocatorException
InterruptedException

setPostConnectAction

void setPostConnectAction(ServiceLocator.PostConnectAction postConnectAction)


Copyright © 2011 Talend Inc.. All Rights Reserved.