Skip to main content
Jump to: navigation, search

Discovery and Distribution Listeners

ECF's implementation of RFC119 has a listener service API, so that clients can monitor and respond to the activities of the implementation during service registration and service publication (on the service host), and service discovery and service lookup/proxy creation (on the service consumer).

For all of the listener interfaces below, the way for clients to create listeners is to use the whiteboard pattern to

  1. Create an instance of the interface
  2. Register the instance as a service

When appropriate events occur (i.e. a RFC119 remote service is registered), the ECF RFC119 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

// define class to implement IHostDistributionListener
public class MyHostDistributionListener implements IHostDistributionListener {
  public void registered(ServiceReference serviceReference,
      IRemoteServiceContainer remoteServiceContainer, IRemoteServiceRegistration remoteRegistration) {
  public void unregistered(ServiceReference serviceReference, IRemoteServiceRegistration remoteRegistration) {
// register new instance of MyHostDistributionListener as OSGi service
bundleContext.registerService(IHostDistributionListener.class.getName(),new MyHostDistributionListener(),null);

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

  1. IHostDistributionListener - Notified when a remote service is registered and unregistered.
  2. IHostDiscoveryListener - Notified when the remote service is published or unpublished for remote discovery.

Service Consumer

On the service consumer there are also two listeners

  1. IProxyDiscoveryListener - Notified when a remote service is discovered.
  2. 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 package, while the distribution listeners are in the package.

Back to the top