OSGi Getting Started

By Michael N. Lipp

Mastodon Follow

View GitHub Project

Introduction

Part 1: The container

Part 2: Simplest Bundle

Part 3: Simple Bundle

Part 4: Eclipse (OSGi) Plugin

Part 5: Bndtools

Part 6: Shift in Perspective

Part 7: Modules and Services

Part 8: Accessing a Service

Part 9: Tracking a Service

Part 10: Using a Service

Part 11: Providing a Service

Interlude: Cleaning up

Part 12: Configuration Admin

Part 13: Service Components

Part 14: Repositories

Part 15: Versions

Why?

You find a lot of tutorials about OSGi on the web. Why add another introduction to OSGi? Well, the usual reason: they didn’t really help me. I want to understand things from the ground up, and I want that ground to be as simple as possible.

Most tutorials that I have found are centered around some tool that is supposed to overcome the difficulties of OSGi. But is OSGi really so difficult to master? No it isn’t. You just mustn’t start with complex tools or patterns. Knowing the JDK and its basic tools is quite sufficient. Of course, you should also have some general knowledge about modular programming and component based software, because OSGi is basically about how to build and use modularized and component based applications with a given framework.

The examples used in this introduction are available from the project site as an Eclipse project. I know that there are other IDEs around, but that’s the one I prefer. For the initial parts of this introduction, the IDE is actually irrelevant. If you want to, you can use a text editor and build the examples with javac and jar. There are also gradle build configurations provided that automate those compilation and packaging steps1.

I have started this introduction in spring 2016 and added and updated some parts since. In the meantime, others have written about OSGi as well, but I still think that my approach is a good starting point for anybody who wants to gain in-depth knowledge about OSGi. One notable additional introduction that has been added to the lot is “OSGi Starter” by Peter Kriens2. He focuses more on the usage of the available tools and less on introducing the concepts, but I might not have started this project if his introduction had been available when I looked at OSGi for the first time.

If you want to comment on this introduction, please use the links at the bottom of the pages.


  1. No maven inside! I think maven is the worst thing that has ever happened to Java development. Neil Ford has described the issue very nicely (and far less emotionally than I ever could). 

  2. One of the drivers behind OSGi.