Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * Service Locator Client for CXF
   * %%
   * Copyright (C) 2011 Talend Inc.
   * %%
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * 
  *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * #L%
  */
 package org.talend.esb.servicelocator.client;
 
 import java.util.List;
 
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.

  • An endpoint for a specific service can be registered.
  • All live endpoints for a specific service that were registered before by other clients can be looked up.
  • All services for which an endpoint was ever registered can be retrieved.
  • For a specific service all endpoints that were ever registered can be retrieved whether they are currently live or not.
 
 public interface ServiceLocator {

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:
java.lang.InterruptedException the current Thread was interrupted when waiting for a successful connection to the ServiceLocator
ServiceLocatorException the connect operation failed
 
 	void connect() throws InterruptedException,
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:
java.lang.InterruptedException the current Thread was interrupted when waiting for the disconnect to happen
ServiceLocatorException
 
 	void disconnect() throws 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
java.lang.InterruptedException the current Thread was interrupted when waiting for a response of the ServiceLocator
	void register(QName serviceNameString endpoint)
	void register(QName serviceNameString endpointSLProperties properties)
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
java.lang.InterruptedException the current Thread was interrupted when waiting for a response of the ServiceLocator
	void unregister(QName serviceNameString endpoint)
    void removeEndpoint(QName serviceNameString endpoint)
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
java.lang.InterruptedException the current Thread was interrupted when waiting for a response of the ServiceLocator
	SLEndpoint getEndpoint(final QName serviceNamefinal String endpoint)
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
java.lang.InterruptedException the current Thread was interrupted when waiting for a response of the ServiceLocator
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
java.lang.InterruptedException the current Thread was interrupted when waiting for a response of the ServiceLocator
	List<Stringlookup(QName serviceName)
    List<Stringlookup(QName serviceNameSLPropertiesMatcher matcher)
    void setPostConnectAction(PostConnectAction postConnectAction);

Callback interface to define actions that must be executed after a successful connect or reconnect.
	static interface PostConnectAction {
Execute this after the connection to the Service Locator is established or re-established.

Parameters:
lc the Service Locator client that just successfully connected to the server, must not be null
	}
New to GrepCode? Check out our FAQ X