Tutorial 1: The Basics
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.
The Prerequisites
Before you start this tutorial you should have:
-
An understanding of the capabilities of the OSGi Service Platform
and the OSGi service registry. Details of the OSGi Service Platform
can be found at the
OSGi Alliance.
-
Installed the SAT runtime bundles.
-
An understanding of how to use the Plug-in Development Environment (PDE)
tooling to
create a plug-in project, manage a plug-in project's metadata files
using the
manifest editor, and how to launch the
Equinox OSGi framework from within the Eclipse IDE.
The Vendor Application
The diagram on the right shows the topology of the tutorial application.
-
Starting at the bottom of the diagram, the yellow Vendor Service bundle
is a library bundle that exports a package into the OSGi framework. The
package contains the Java interface
VendorService.
-
Both the green Hotdog Vendor bundle and the Popcorn Vendor bundle import
the package that is exported by the Vendor Service bundle, since they
have Java code dependencies on the
VendorService interface.
-
Both the green Hotdog Vendor bundle and Popcorn Vendor bundle register
an implementation of the
VendorService with the OSGi
framework.
-
The blue Customer bundle is a leaf bundle since it is at the top of the
bundle food chain. The Customer bundle imports the package exported by
the Vendor Service bundle since it has Java code dependencies on the
VendorService interface.
-
The blue Customer bundle acquires an implementation of the
VendorService from the OSGi framework. The Customer bundle
does not, and should not, care whether it acquires the Hotdog Vendor or
the Popcorn Vendor implementation of the service.
The Steps
This tutorial consists of the following steps:
-
Create 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.
-
Create 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.
-
Create 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.
-
Create 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.
-
Launching the Vendor Application: In this step the Equinox OSGi
Framework will be launched with our application bundles installed and
started.
-
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.
Copyright © 2001, 2007 IBM Corporation and others. All Rights Reserved.