OSGi : Lab

From CDOT Wiki
Jump to: navigation, search

OSGi Lab Activities - The LAB DUE DATE is in two weeks from the time the lab is defined (for example, the Basics lab is defined in the second week and its due date is in the fourth week; the lab for OSGi is defined in the fourth week and its deadline is in the sixth week, and so forth...)


  • Start and run the OSGi Eclipse.
  • Define the workspace as: ./wksp/OSGi/lab
  • Create a project based on the application defined below in description section.
  • Develop the application, Run and Debug it.
  • When the application runs as expected, Open the Subversion Perspective in OSGi Eclipse and upload the application to the repository that was given to you at the beginning of this course.
  • Write a detailed tutorial about using OSGi Eclipse to develop such an application. The tutorial must be written in wiki / html / ppt / pdf format (choose the format that is more convenient to your team) . Checkin in the repository your tutorial, if the format allows it. (if not, (i.e. if your format does not allow you to store it in your repository), then define in your repository only the address of your tutorial). Thus, the url address stored in the repository, can be used to read your tutorial; (for instance, if your tutorial is in wiki format store in the repository the address of wiki tutorial).

Individual Deliverable:

  • Each student must create a web page in his/her zenit account course that contains student identification (student name; picture, wiki address, etc., and for every lab, one should define the links to the repository of his/her work - code, tutorial, etc.; you do not have to send any email with the address of your web page).

Team Deliverable:

  • WHEN requested you must send an email to Jordan Anastasiade with the address of your repository



OSGi Lab Application Description: In OSGi, a service is a plain java object which is published to a registry. A consumer can consume the registered service through lookup. Service is built using interface-based programming model. To build a service one must basically provide implementation of a interface. To consume, one only need the interface for the lookup (there is no need for the consumer to know about the service implementation). Before starting working at your lab, please take a look at an example of services implemented in the book OSGi and Equinox, Creating Highly Modular Java Systems


Your Lab must define an OSGi service and a service consumption. Please find below the steps necessary to build such a system.

  1. Create the Service Interface
    1. Define the service interface
    2. Create the bundle with the interface
  2. Implement the Service Provider
    1. Register the service in the class Activator.
    2. Define the MANIFEST.MF for the service provider bundle.
    3. Install and run the Service Provider Bundle
  3. Implement the Service Consumer
    1. Define the MANIFEST.MF for the service consumer bundle.
    2. Use the class Activator to find the service.
    3. Implement a class where one can consume the service.
    4. Install and run the Service Consumer Bundle.

Important note: The client (service consumer) must have a GUI interface

Your lab will be marked based on the following criteria: Please find them below in the order of their importance:

  1. The correctness of the system design (see the OSGi service architecture).
  2. The complexity of your OSGi service provider.
  3. The design and implementation of the GUI for the service consumer.
  4. The clarity and usefulness of your tutorial.

Your tutorial must be stored in your repository. If the tutorial format cannot be stored there (e.g. the wiki format), then its address must be stored in the repository. In either case your tutorial must be registered as an entry at the course tutorial resources.


Important note: Do not forget to register your tutorial at our course resources.


There is an example for your lab here. The sample builds an OSGi voting system.

The solution for the first Lab (Fall 2011) could be found here