Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Like normal, we must create a manifest.mf file that contains the meta-data for our bundle:

No Format
Bundle-Activator: tutorial.example4.Activator
Import-Package: tutorial.example2.service
Bundle-Name: Dynamic dictionary client
Bundle-Description: A bundle that uses the dictionary service whenever it becomes available
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: tutorial.example4.Activator
Import-Package: org.osgi.framework,
 tutorial.example2.service

We specify the class to activate our bundle via the Bundle-Activator attribute and also specify that our bundle imports the shared core OSGi framework package of and the dictionary service interface package using the Import-Package attribute. This import clause will be fulfilled by the bundle in Example 2, which exports the package that this bundle is importing. The OSGi framework will automatically handle the details of resolving import packages.

...

Since this client monitors the dynamic availability of the dictionary service, it is robust in the face of sudden departures of the the dictionary service. Further, when a dictionary service arrives, it automatically gets the service if it needs it and continues to function. These capabilities are a little difficult to demonstrate since we are using a simple single-threaded approach, but in a multi-threaded or GUI-oriented application this robustness is very useful.