Skip to main content
Jump to: navigation, search

Difference between revisions of "Discovery and Distribution Listeners"

 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
ECF's implementation of OSGi remote services has a listener API, so that clients can monitor and respond to the activities of the implementation during service registration  (on the remote service host), and service discovery and service lookup/proxy creation (on the remote service consumer).
+
Deprecated in favor of [[Remote_Services_Admin | Remote Services Admin]] implementation.
 
+
For all of the listener interfaces below, the way for clients to create listeners is to use the whiteboard pattern to
+
 
+
# Create an instance of the interface
+
# Register the instance as a service
+
 
+
When appropriate events occur (i.e. a remote service is registered), the ECF remote services impl will find all registered IHostDistributionListener services and notify them by calling the appropriate event method.
+
 
+
For example, here is how one would create and register a IHostDistributionListener
+
 
+
<source lang="java">
+
// define class to implement IHostDistributionListener
+
public class MyHostDistributionListener implements IHostDistributionListener {
+
  public void registered(ServiceReference serviceReference,
+
      IRemoteServiceContainer remoteServiceContainer, IRemoteServiceRegistration remoteRegistration) {
+
    System.out.println("hostRegistered\n\tserviceReference="+serviceReference+"\n\tremoteServiceContainer="+remoteServiceContainer+"\n\tremoteRegistration="+remoteRegistration);
+
  }
+
 
+
  public void unregistered(ServiceReference serviceReference, IRemoteServiceRegistration remoteRegistration) {
+
    System.out.println("hostUnregistered\n\tserviceReference="+serviceReference+"\n\tremoteRegistration="+remoteRegistration);
+
  }
+
}
+
...
+
// register new instance of MyHostDistributionListener as OSGi service
+
bundleContext.registerService(IHostDistributionListener.class.getName(),new MyHostDistributionListener(),null);
+
</source>
+
 
+
When a remote service is registered, the 'registered' method will be called, and when a remote service is unregistered the 'unregistered' method will be called.
+
 
+
===Service Host===
+
 
+
On the service host there are two listeners
+
 
+
# [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/osgi/services/distribution/IHostDistributionListener.html IHostDistributionListener] - Notified when a remote service is registered and unregistered. 
+
# [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/osgi/services/discovery/IHostDiscoveryListener.html IHostDiscoveryListener] - Notified when the remote service is published or unpublished for remote discovery.
+
 
+
===Service Consumer===
+
 
+
On the service consumer there are also two listeners
+
 
+
# [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/osgi/services/discovery/IProxyDiscoveryListener.html IProxyDiscoveryListener] - Notified when a remote service is discovered.
+
# [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/osgi/services/distribution/IProxyDistributionListener.html IProxyDistributionListener] - Notified when an ECF container is selected for distribution, and when remote reference lookup occurs, and proxy is finally created and registered in local service registry.
+
 
+
The two discovery listeners are in the [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/osgi/services/discovery/package-frame.html org.eclipse.ecf.osgi.services.discovery] package, while the distribution listeners are in the [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/osgi/services/distribution/package-frame.html org.eclipse.ecf.osgi.services.distribution] package.
+

Latest revision as of 09:28, 9 May 2011

Deprecated in favor of Remote Services Admin implementation.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.