org.apache.felix.examples.spellcheckservice.impl
Class Activator

java.lang.Object
  extended by org.apache.felix.examples.spellcheckservice.impl.Activator
All Implemented Interfaces:
java.util.EventListener, org.osgi.framework.BundleActivator, org.osgi.framework.ServiceListener

public class Activator
extends java.lang.Object
implements org.osgi.framework.BundleActivator, org.osgi.framework.ServiceListener

This class implements a bundle that implements a spell check service. The spell check service uses all available dictionary services to check for the existence of words in a given sentence. This bundle not only monitors the dynamic availability of dictionary services, but it manages the aggregation of all available dictionary services as they arrive and depart. The spell check service is only registered if there are dictionary services available, thus the spell check service will appear and disappear as dictionary services appear and disappear, respectively.

Author:
Felix Project Team

Constructor Summary
Activator()
           
 
Method Summary
 void serviceChanged(org.osgi.framework.ServiceEvent event)
          Implements ServiceListener.serviceChanged().
 void start(org.osgi.framework.BundleContext context)
          Implements BundleActivator.start().
 void stop(org.osgi.framework.BundleContext context)
          Implements BundleActivator.stop().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Activator

public Activator()
Method Detail

start

public void start(org.osgi.framework.BundleContext context)
           throws java.lang.Exception
Implements BundleActivator.start(). Adds itself as a service listener and queries for all currently available dictionary services. Any available dictionary services are added to the service reference list. If dictionary services are found, then the spell check service is registered.

Specified by:
start in interface org.osgi.framework.BundleActivator
Parameters:
context - the framework context for the bundle.
Throws:
java.lang.Exception

stop

public void stop(org.osgi.framework.BundleContext context)
Implements BundleActivator.stop(). Does nothing since the framework will automatically unregister any registered services, release any used services, and remove any event listeners.

Specified by:
stop in interface org.osgi.framework.BundleActivator
Parameters:
context - the framework context for the bundle.

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent event)
Implements ServiceListener.serviceChanged(). Monitors the arrival and departure of dictionary services, adding and removing them from the service reference list, respectively. In the case where no more dictionary services are available, the spell check service is registered. As soon as any dictionary spell check becomes available, the spell check service is reregistered.

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
event - the fired service event.