Tutorial 1: Exporting and Importing Services

The goal of this tutorial is to teach the use of the Service Activator Toolkit through the development of some simple service-oriented bundles. The tutorial is simple and focuses on understanding how best to use SAT to build service-oriented bundles rather than teaching OSGi.

After completing this tutorial you will have an understanding of how to build service-oriented bundles with SAT, how to register exported services, and how to acquire imported services.

The Prerequisites

Before you start this tutorial you should have:

Tutorial 1

The Vendor Application

The diagram on the right shows the topology of the tutorial application.

The Steps

This tutorial consists of the following steps:

  1. Creating the Vendor Service Bundle: In this step the Vendor Service library bundle is created that exports a package that contains the VendorService interface. Other bundles will create implementations of this interface and register them with the OSGi framework, while others will acquire an implementation of this interface from the OSGi framework.
  2. Creating the Hotdog Vendor Bundle: In this step the Hotdog Vendor bundle is created that imports the package containing the VendorService interface and registers an implementation of the service with the OSGi framework.
  3. Creating the Popcorn Vendor Bundle: In this step the Popcorn Vendor bundle is created that also imports the package containing the VendorService interface and registers an implementation of the service with the OSGi framework.
  4. Creating the Customer Bundle: In this step the Customer bundle is created that imports the package containing the VendorService interface and acquires an implementation of the interface from the OSGi framework.
  5. Launching the Vendor Application: In this step the Equinox OSGi Framework will be launched with our application bundles installed and started.
  6. Testing the Vendor Application: In this step the application will be tested using the OSGi console commands.

Source Projects

The source projects for this tutorial are available as a zip file that may be extracted into the file system and imported into your Eclipse workspace.