OSGi Getting Started

By Michael N. Lipp

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: Accessing a Service

Part 8: Tracking a Service

Part 9: Using a Service

Interlude: Cleaning up

Part 10: Service Component

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.

If you want to comment on this introduction, simply enter your remarks as a project issue.


  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).