Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

We specify which class used to activate the bundle via the Bundle-Activator attribute. Our bundle exports the spell checker service interface using the Export-Package attribute and imports the OSGi core framework and dictionary service interface packages using the Import-Package attribute. (Note: Make sure your manifest file ends in a trailing carriage return or else the last line will be ignored.)

To compile our source, we need to have the felix.jar file (found in Felix' bin directory) and the example2.jar file in our class path. We compile the source file using a command like:

...

To run Felix, we follow the instructions described in usage.html. When we start Felix, it asks for a profile name, we will put all of our bundles in a profile named tutorial. After running Felix, we should stop all tutorial bundles except for the service bundles. Use the ps lb command to make sure that only the bundles from Example 2 and Example 2b are active; use the start and stop commands as appropriate to start and stop the various tutorial bundles, respectively. (Note: Felix uses some bundles to provide its command shell, so do not stop these bundles.) Now we can install and start our spell checker service bundle. Assuming that we created our bundle in the directory c:\tutorial, we can install and start it in Felix' shell using the following command:

...

The above command installs and starts the bundle in a single step; it is also possible to install and start the bundle in two steps by using the Felix install and start shell commands. To stop the bundle, use the Felix stop shell command. Using the Felix shell ps lb command to get the bundle identifier number for our spell checker service bundle and we can stop and restart it at will using the stop and start commands, respectively. Using the services command, we can see which services are currently available in the OSGi framework, including our dictionary and spell checker services. We can experiment with our spell checker service's dynamic availability by stopping the dictionary service bundles; when both dictionary services are stopped, the services command will reveal that our bundle is no longer offering its spell checker service. Likewise, when the dictionary services comeback, so will our spell checker service. We create a client for our spell checker service in Example 7. To exit Felix, we use the shutdown command.