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: Modules and Services

Part 8: Accessing a Service

Part 9: Tracking a Service

Part 10: Using a Service

Interlude: Cleaning up

Part 11: Service Component

Part 12: Repositories

Part 13: Versions

The Container

In the simplest case of component based development, the components are assembled using some static configuration. More advanced concepts introduce a container as execution environment and allow you to dynamically add or remove components at runtime.

In OSGi terms, the container is provided by the OSGi framework and the components are provided by OSGi (compliant) bundles1. So in order to get started with OSGi, we need an OSGi framework. There are several implementations of the framework available. Let’s use Apache Felix to get started, because I found that to be very intuitive and easy to use.

I won’t repeat things here that have already been well described by others. So simply go to the Apache Felix Framework Usage Documentation and follow it up to and including the section “Starting the framework”. Make sure to only download the Felix Framework Distribution and none of the subprojects (yet).

After starting the framework, type “felix:lb” (short for “list bundles”) and you’ll get something like this:

START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (6.0.2)|6.0.2
    1|Active     |    1|jansi (1.17.1)|1.17.1
    2|Active     |    1|JLine Bundle (3.7.0)|3.7.0
    3|Active     |    1|Apache Felix Bundle Repository (2.0.10)|2.0.10
    4|Active     |    1|Apache Felix Gogo Command (1.0.2)|1.0.2
    5|Active     |    1|Apache Felix Gogo JLine Shell (1.1.0)|1.1.0
    6|Active     |    1|Apache Felix Gogo Runtime (1.1.0)|1.1.0

An “empty” OSGi runtime environment doesn’t seem to be really empty. It already contains some bundles. As we can guess from the “Level” it’s maybe not really necessary to have the “Apache Felix …” bundles, but most likely we need the “System bundle”.

Let’s see if we can find out a bit more about that bundle. Type “felix:headers 0” and you get:

System Bundle (0)
-----------------
Bundle-Description = This bundle is system specific; it implements various system services.
Bundle-ManifestVersion = 2
Bundle-Name = System Bundle
Bundle-SymbolicName = org.apache.felix.framework
Bundle-Version = 6.0.2
Export-Package = org.osgi.framework; version="1.9.0", org.osgi.framework.dto; uses:="org.osgi.dto"; version="1.8.0", org.osgi.framework.hooks.bundle; uses:="org.osgi.framework"; version="1.1.0", org.osgi.framework.hooks.resolver; uses:="org.osgi.framework.wiring"; version="1.0.0", org.osgi.framework.hooks.service; uses:="org.osgi.framework"; version="1.1.0", org.osgi.framework.hooks.weaving; uses:="org.osgi.framework.wiring"; version="1.1.0", org.osgi.framework.launch; uses:="org.osgi.framework"; version="1.2.0", org.osgi.framework.namespace; uses:="org.osgi.resource"; version="1.1.0", org.osgi.framework.startlevel; uses:="org.osgi.framework"; version="1.0.0", org.osgi.framework.startlevel.dto; uses:="org.osgi.dto"; version="1.0.0", org.osgi.framework.wiring; uses:="org.osgi.framework,org.osgi.resource"; version="1.2.0", org.osgi.framework.wiring.dto; uses:="org.osgi.dto,org.osgi.resource.dto"; version="1.3.0", org.osgi.resource; version="1.0.0", org.osgi.resource.dto; uses:="org.osgi.dto"; version="1.0.0", org.osgi.service.packageadmin; uses:="org.osgi.framework"; version="1.2.0", org.osgi.service.startlevel; uses:="org.osgi.framework"; version="1.1.0", org.osgi.service.url; version="1.0.0", org.osgi.service.resolver; uses:="org.osgi.resource"; version="1.1.0", org.osgi.util.tracker; uses:="org.osgi.framework"; version="1.5.2", org.osgi.dto; version="1.1.0", java.applet; version="0.0.0.JavaSE_001_008", java.awt; version="0.0.0.JavaSE_001_008", java.awt.color; version="0.0.0.JavaSE_001_008", java.awt.datatransfer; version="0.0.0.JavaSE_001_008", java.awt.dnd; version="0.0.0.JavaSE_001_008", java.awt.event; version="0.0.0.JavaSE_001_008", java.awt.font; version="0.0.0.JavaSE_001_008", java.awt.geom; version="0.0.0.JavaSE_001_008", java.awt.im; version="0.0.0.JavaSE_001_008", java.awt.im.spi; version="0.0.0.JavaSE_001_008", java.awt.image; version="0.0.0.JavaSE_001_008", java.awt.image.renderable; version="0.0.0.JavaSE_001_008", java.awt.print; version="0.0.0.JavaSE_001_008", java.beans; version="0.0.0.JavaSE_001_008", java.beans.beancontext; version="0.0.0.JavaSE_001_008", java.io; version="0.0.0.JavaSE_001_008", java.lang; version="0.0.0.JavaSE_001_008", java.lang.annotation; version="0.0.0.JavaSE_001_008", java.lang.instrument; version="0.0.0.JavaSE_001_008", java.lang.management; version="0.0.0.JavaSE_001_008", java.lang.ref; version="0.0.0.JavaSE_001_008", java.lang.reflect; version="0.0.0.JavaSE_001_008", java.math; version="0.0.0.JavaSE_001_008", java.net; version="0.0.0.JavaSE_001_008", java.nio; version="0.0.0.JavaSE_001_008", java.nio.channels; version="0.0.0.JavaSE_001_008", java.nio.channels.spi; version="0.0.0.JavaSE_001_008", java.nio.charset; version="0.0.0.JavaSE_001_008", java.nio.charset.spi; version="0.0.0.JavaSE_001_008", java.rmi; version="0.0.0.JavaSE_001_008", java.rmi.activation; version="0.0.0.JavaSE_001_008", java.rmi.dgc; version="0.0.0.JavaSE_001_008", java.rmi.registry; version="0.0.0.JavaSE_001_008", java.rmi.server; version="0.0.0.JavaSE_001_008", java.security; version="0.0.0.JavaSE_001_008", java.security.acl; version="0.0.0.JavaSE_001_008", java.security.cert; version="0.0.0.JavaSE_001_008", java.security.interfaces; version="0.0.0.JavaSE_001_008", java.security.spec; version="0.0.0.JavaSE_001_008", java.sql; version="0.0.0.JavaSE_001_008", java.text; version="0.0.0.JavaSE_001_008", java.text.spi; version="0.0.0.JavaSE_001_008", java.util; version="0.0.0.JavaSE_001_008", java.util.concurrent; version="0.0.0.JavaSE_001_008", java.util.concurrent.atomic; version="0.0.0.JavaSE_001_008", java.util.concurrent.locks; version="0.0.0.JavaSE_001_008", java.util.jar; version="0.0.0.JavaSE_001_008", java.util.logging; version="0.0.0.JavaSE_001_008", java.util.prefs; version="0.0.0.JavaSE_001_008", java.util.regex; version="0.0.0.JavaSE_001_008", java.util.spi; version="0.0.0.JavaSE_001_008", java.util.zip; version="0.0.0.JavaSE_001_008", javax.accessibility; uses:="javax.swing.text"; version="0.0.0.JavaSE_001_008", javax.activation; version="0.0.0.JavaSE_001_008", javax.activity; version="0.0.0.JavaSE_001_008", javax.annotation; version="0.0.0.JavaSE_001_008", javax.annotation.processing; uses:="javax.lang.model,javax.lang.model.element,javax.lang.model.util,javax.tools"; version="0.0.0.JavaSE_001_008", javax.crypto.interfaces; uses:="javax.crypto,javax.crypto.spec"; version="0.0.0.JavaSE_001_008", javax.crypto.spec; uses:="javax.crypto"; version="0.0.0.JavaSE_001_008", javax.imageio; uses:="javax.imageio.event,javax.imageio.metadata,javax.imageio.spi,javax.imageio.stream"; version="0.0.0.JavaSE_001_008", javax.imageio.event; uses:="javax.imageio"; version="0.0.0.JavaSE_001_008", javax.imageio.metadata; uses:="javax.imageio,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.imageio.plugins.bmp; uses:="javax.imageio"; version="0.0.0.JavaSE_001_008", javax.imageio.plugins.jpeg; uses:="javax.imageio"; version="0.0.0.JavaSE_001_008", javax.imageio.spi; uses:="javax.imageio,javax.imageio.metadata,javax.imageio.stream"; version="0.0.0.JavaSE_001_008", javax.imageio.stream; uses:="javax.imageio"; version="0.0.0.JavaSE_001_008", javax.jws; version="0.0.0.JavaSE_001_008", javax.jws.soap; version="0.0.0.JavaSE_001_008", javax.lang.model.util; uses:="javax.annotation.processing,javax.lang.model,javax.lang.model.element,javax.lang.model.type"; version="0.0.0.JavaSE_001_008", javax.management; uses:="javax.management.loading,javax.management.openmbean"; version="0.0.0.JavaSE_001_008", javax.management.loading; uses:="javax.management"; version="0.0.0.JavaSE_001_008", javax.management.modelmbean; uses:="javax.management,javax.management.loading"; version="0.0.0.JavaSE_001_008", javax.management.openmbean; uses:="javax.management"; version="0.0.0.JavaSE_001_008", javax.management.relation; uses:="javax.management"; version="0.0.0.JavaSE_001_008", javax.management.remote; uses:="javax.management,javax.security.auth"; version="0.0.0.JavaSE_001_008", javax.management.remote.rmi; uses:="javax.management,javax.management.loading,javax.management.remote,javax.naming,javax.rmi,javax.rmi.CORBA,javax.rmi.ssl,javax.security.auth,org.omg.CORBA,org.omg.CORBA.portable,org.omg.CORBA_2_3.portable"; version="0.0.0.JavaSE_001_008", javax.management.timer; uses:="javax.management"; version="0.0.0.JavaSE_001_008", javax.naming; uses:="javax.naming.spi"; version="0.0.0.JavaSE_001_008", javax.naming.directory; uses:="javax.naming"; version="0.0.0.JavaSE_001_008", javax.naming.event; uses:="javax.naming,javax.naming.directory"; version="0.0.0.JavaSE_001_008", javax.naming.ldap; uses:="javax.naming,javax.naming.directory,javax.naming.event,javax.net.ssl"; version="0.0.0.JavaSE_001_008", javax.naming.spi; uses:="javax.naming,javax.naming.directory"; version="0.0.0.JavaSE_001_008", javax.net; version="0.0.0.JavaSE_001_008", javax.net.ssl; uses:="javax.net,javax.security.auth.x500,javax.security.cert"; version="0.0.0.JavaSE_001_008", javax.print; uses:="javax.print.attribute,javax.print.attribute.standard,javax.print.event"; version="0.0.0.JavaSE_001_008", javax.print.attribute; version="0.0.0.JavaSE_001_008", javax.print.attribute.standard; uses:="javax.print.attribute"; version="0.0.0.JavaSE_001_008", javax.print.event; uses:="javax.print,javax.print.attribute"; version="0.0.0.JavaSE_001_008", javax.rmi; uses:="javax.rmi.CORBA,org.omg.CORBA"; version="0.0.0.JavaSE_001_008", javax.rmi.CORBA; uses:="org.omg.CORBA,org.omg.CORBA.portable,org.omg.CORBA_2_3.portable,org.omg.SendingContext"; version="0.0.0.JavaSE_001_008", javax.rmi.ssl; uses:="javax.net,javax.net.ssl"; version="0.0.0.JavaSE_001_008", javax.script; version="0.0.0.JavaSE_001_008", javax.security.auth; version="0.0.0.JavaSE_001_008", javax.security.auth.callback; version="0.0.0.JavaSE_001_008", javax.security.auth.kerberos; uses:="javax.crypto,javax.security.auth"; version="0.0.0.JavaSE_001_008", javax.security.auth.login; uses:="javax.security.auth,javax.security.auth.callback"; version="0.0.0.JavaSE_001_008", javax.security.auth.spi; uses:="javax.security.auth,javax.security.auth.callback,javax.security.auth.login"; version="0.0.0.JavaSE_001_008", javax.security.auth.x500; uses:="javax.security.auth"; version="0.0.0.JavaSE_001_008", javax.security.cert; version="0.0.0.JavaSE_001_008", javax.security.sasl; uses:="javax.security.auth.callback"; version="0.0.0.JavaSE_001_008", javax.sound.midi; uses:="javax.sound.midi.spi"; version="0.0.0.JavaSE_001_008", javax.sound.midi.spi; uses:="javax.sound.midi"; version="0.0.0.JavaSE_001_008", javax.sound.sampled; uses:="javax.sound.sampled.spi"; version="0.0.0.JavaSE_001_008", javax.sound.sampled.spi; uses:="javax.sound.sampled"; version="0.0.0.JavaSE_001_008", javax.sql; uses:="javax.transaction.xa"; version="0.0.0.JavaSE_001_008", javax.sql.rowset; uses:="javax.sql,javax.sql.rowset.serial,javax.sql.rowset.spi"; version="0.0.0.JavaSE_001_008", javax.sql.rowset.serial; uses:="javax.sql.rowset"; version="0.0.0.JavaSE_001_008", javax.sql.rowset.spi; uses:="javax.naming,javax.sql,javax.sql.rowset"; version="0.0.0.JavaSE_001_008", javax.swing; uses:="javax.accessibility,javax.print,javax.print.attribute,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.plaf.metal,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.tree"; version="0.0.0.JavaSE_001_008", javax.swing.border; uses:="javax.swing"; version="0.0.0.JavaSE_001_008", javax.swing.event; uses:="javax.swing,javax.swing.table,javax.swing.text,javax.swing.tree,javax.swing.undo"; version="0.0.0.JavaSE_001_008", javax.swing.filechooser; uses:="javax.swing"; version="0.0.0.JavaSE_001_008", javax.swing.plaf; uses:="javax.accessibility,javax.swing,javax.swing.border,javax.swing.filechooser,javax.swing.text,javax.swing.tree"; version="0.0.0.JavaSE_001_008", javax.swing.plaf.metal; uses:="javax.swing,javax.swing.border,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.text,javax.swing.tree"; version="0.0.0.JavaSE_001_008", javax.swing.plaf.multi; uses:="javax.accessibility,javax.swing,javax.swing.filechooser,javax.swing.plaf,javax.swing.text,javax.swing.tree"; version="0.0.0.JavaSE_001_008", javax.swing.table; uses:="javax.accessibility,javax.swing,javax.swing.border,javax.swing.event,javax.swing.plaf"; version="0.0.0.JavaSE_001_008", javax.swing.text; uses:="javax.accessibility,javax.print,javax.print.attribute,javax.swing,javax.swing.event,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.text.html,javax.swing.tree,javax.swing.undo"; version="0.0.0.JavaSE_001_008", javax.swing.text.html; uses:="javax.accessibility,javax.swing,javax.swing.border,javax.swing.event,javax.swing.plaf,javax.swing.text,javax.swing.undo"; version="0.0.0.JavaSE_001_008", javax.swing.text.html.parser; uses:="javax.swing.text,javax.swing.text.html"; version="0.0.0.JavaSE_001_008", javax.swing.text.rtf; uses:="javax.swing.text"; version="0.0.0.JavaSE_001_008", javax.swing.tree; uses:="javax.swing,javax.swing.border,javax.swing.event,javax.swing.plaf,javax.swing.plaf.basic"; version="0.0.0.JavaSE_001_008", javax.swing.undo; uses:="javax.swing,javax.swing.event"; version="0.0.0.JavaSE_001_008", javax.tools; uses:="javax.annotation.processing,javax.lang.model,javax.lang.model.element"; version="0.0.0.JavaSE_001_008", javax.transaction; version="0.0.0.JavaSE_001_008", javax.transaction.xa; version="0.0.0.JavaSE_001_008", javax.xml; version="0.0.0.JavaSE_001_008", javax.xml.bind; uses:="javax.xml.bind.annotation,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.datatype,javax.xml.namespace,javax.xml.stream,javax.xml.transform,javax.xml.transform.stream,javax.xml.validation,org.w3c.dom,org.xml.sax"; version="0.0.0.JavaSE_001_008", javax.xml.bind.annotation; uses:="javax.xml.bind,javax.xml.parsers,javax.xml.transform,javax.xml.transform.dom,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.xml.bind.annotation.adapters; uses:="javax.xml.bind"; version="0.0.0.JavaSE_001_008", javax.xml.bind.attachment; uses:="javax.activation"; version="0.0.0.JavaSE_001_008", javax.xml.bind.helpers; uses:="javax.xml.bind,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.parsers,javax.xml.stream,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stream,javax.xml.validation,org.w3c.dom,org.xml.sax"; version="0.0.0.JavaSE_001_008", javax.xml.bind.util; uses:="javax.xml.bind,javax.xml.transform.sax,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers"; version="0.0.0.JavaSE_001_008", javax.xml.crypto; uses:="javax.xml.crypto.dsig.keyinfo"; version="0.0.0.JavaSE_001_008", javax.xml.crypto.dom; uses:="javax.xml.crypto,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.xml.crypto.dsig; uses:="javax.xml.crypto,javax.xml.crypto.dsig.keyinfo,javax.xml.crypto.dsig.spec"; version="0.0.0.JavaSE_001_008", javax.xml.crypto.dsig.dom; uses:="javax.xml.crypto,javax.xml.crypto.dom,javax.xml.crypto.dsig,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.xml.crypto.dsig.keyinfo; uses:="javax.xml.crypto"; version="0.0.0.JavaSE_001_008", javax.xml.crypto.dsig.spec; uses:="javax.xml.crypto"; version="0.0.0.JavaSE_001_008", javax.xml.datatype; uses:="javax.xml.namespace"; version="0.0.0.JavaSE_001_008", javax.xml.namespace; version="0.0.0.JavaSE_001_008", javax.xml.parsers; uses:="javax.xml.validation,org.w3c.dom,org.xml.sax,org.xml.sax.helpers"; version="0.0.0.JavaSE_001_008", javax.xml.soap; uses:="javax.activation,javax.xml.namespace,javax.xml.transform,javax.xml.transform.dom,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.xml.stream; uses:="javax.xml.namespace,javax.xml.stream.events,javax.xml.stream.util,javax.xml.transform"; version="0.0.0.JavaSE_001_008", javax.xml.stream.events; uses:="javax.xml.namespace,javax.xml.stream"; version="0.0.0.JavaSE_001_008", javax.xml.stream.util; uses:="javax.xml.namespace,javax.xml.stream,javax.xml.stream.events"; version="0.0.0.JavaSE_001_008", javax.xml.transform; version="0.0.0.JavaSE_001_008", javax.xml.transform.dom; uses:="javax.xml.transform,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.xml.transform.sax; uses:="javax.xml.transform,javax.xml.transform.stream,org.xml.sax,org.xml.sax.ext"; version="0.0.0.JavaSE_001_008", javax.xml.transform.stax; uses:="javax.xml.stream,javax.xml.stream.events,javax.xml.transform"; version="0.0.0.JavaSE_001_008", javax.xml.transform.stream; uses:="javax.xml.transform"; version="0.0.0.JavaSE_001_008", javax.xml.validation; uses:="javax.xml.transform,javax.xml.transform.stream,org.w3c.dom,org.w3c.dom.ls,org.xml.sax"; version="0.0.0.JavaSE_001_008", javax.xml.ws.handler; uses:="javax.xml.namespace,javax.xml.ws"; version="0.0.0.JavaSE_001_008", javax.xml.ws.handler.soap; uses:="javax.xml.bind,javax.xml.namespace,javax.xml.soap,javax.xml.ws.handler"; version="0.0.0.JavaSE_001_008", javax.xml.ws.http; uses:="javax.xml.ws"; version="0.0.0.JavaSE_001_008", javax.xml.ws.soap; uses:="javax.xml.soap,javax.xml.ws,javax.xml.ws.spi"; version="0.0.0.JavaSE_001_008", javax.xml.ws.spi; uses:="javax.xml.bind,javax.xml.namespace,javax.xml.transform,javax.xml.ws,javax.xml.ws.handler,javax.xml.ws.wsaddressing,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.xml.ws.wsaddressing; uses:="javax.xml.bind,javax.xml.bind.annotation,javax.xml.namespace,javax.xml.transform,javax.xml.ws,javax.xml.ws.spi,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.xml.xpath; uses:="javax.xml.namespace,org.xml.sax"; version="0.0.0.JavaSE_001_008", org.ietf.jgss; version="0.0.0.JavaSE_001_008", org.omg.CORBA; uses:="org.omg.CORBA.DynAnyPackage,org.omg.CORBA.ORBPackage,org.omg.CORBA.TypeCodePackage,org.omg.CORBA.portable,org.omg.CORBA_2_3.portable"; version="0.0.0.JavaSE_001_008", org.omg.CORBA.DynAnyPackage; uses:="org.omg.CORBA"; version="0.0.0.JavaSE_001_008", org.omg.CORBA.ORBPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.CORBA.TypeCodePackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.CORBA.portable; uses:="org.omg.CORBA,org.omg.CORBA_2_3.portable"; version="0.0.0.JavaSE_001_008", org.omg.CORBA_2_3; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.CORBA_2_3.portable; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.CosNaming; uses:="org.omg.CORBA,org.omg.CORBA.portable,org.omg.CosNaming.NamingContextExtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.PortableServer"; version="0.0.0.JavaSE_001_008", org.omg.CosNaming.NamingContextExtPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.CosNaming.NamingContextPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable,org.omg.CosNaming"; version="0.0.0.JavaSE_001_008", org.omg.Dynamic; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.DynamicAny; uses:="org.omg.CORBA,org.omg.CORBA.portable,org.omg.DynamicAny.DynAnyFactoryPackage,org.omg.DynamicAny.DynAnyPackage"; version="0.0.0.JavaSE_001_008", org.omg.DynamicAny.DynAnyFactoryPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.DynamicAny.DynAnyPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.IOP; uses:="org.omg.CORBA,org.omg.CORBA.portable,org.omg.IOP.CodecFactoryPackage,org.omg.IOP.CodecPackage"; version="0.0.0.JavaSE_001_008", org.omg.IOP.CodecFactoryPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.IOP.CodecPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.Messaging; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.PortableInterceptor; uses:="org.omg.CORBA,org.omg.CORBA.portable,org.omg.CORBA_2_3.portable,org.omg.Dynamic,org.omg.IOP,org.omg.PortableInterceptor.ORBInitInfoPackage"; version="0.0.0.JavaSE_001_008", org.omg.PortableInterceptor.ORBInitInfoPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.PortableServer; uses:="org.omg.CORBA,org.omg.CORBA.portable,org.omg.CORBA_2_3,org.omg.PortableServer.CurrentPackage,org.omg.PortableServer.POAManagerPackage,org.omg.PortableServer.POAPackage,org.omg.PortableServer.ServantLocatorPackage,org.omg.PortableServer.portable"; version="0.0.0.JavaSE_001_008", org.omg.PortableServer.CurrentPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.PortableServer.POAManagerPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.PortableServer.POAPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.PortableServer.ServantLocatorPackage; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.PortableServer.portable; uses:="org.omg.CORBA,org.omg.PortableServer"; version="0.0.0.JavaSE_001_008", org.omg.SendingContext; uses:="org.omg.CORBA,org.omg.CORBA.portable"; version="0.0.0.JavaSE_001_008", org.omg.stub.java.rmi; uses:="javax.rmi.CORBA"; version="0.0.0.JavaSE_001_008", org.w3c.dom; version="0.0.0.JavaSE_001_008", org.w3c.dom.bootstrap; uses:="org.w3c.dom"; version="0.0.0.JavaSE_001_008", org.w3c.dom.ls; uses:="org.w3c.dom,org.w3c.dom.events"; version="0.0.0.JavaSE_001_008", org.w3c.dom.events; uses:="org.w3c.dom,org.w3c.dom.views"; version="0.0.0.JavaSE_001_008", org.w3c.dom.views; version="0.0.0.JavaSE_001_008", org.w3c.dom.traversal; uses:="org.w3c.dom"; version="0.0.0.JavaSE_001_008", org.w3c.dom.ranges; uses:="org.w3c.dom"; version="0.0.0.JavaSE_001_008", org.w3c.dom.css; uses:="org.w3c.dom,org.w3c.dom.stylesheets,org.w3c.dom.views"; version="0.0.0.JavaSE_001_008", org.w3c.dom.html; uses:="org.w3c.dom"; version="0.0.0.JavaSE_001_008", org.w3c.dom.stylesheets; uses:="org.w3c.dom"; version="0.0.0.JavaSE_001_008", org.w3c.dom.xpath; uses:="org.w3c.dom"; version="0.0.0.JavaSE_001_008", org.xml.sax; version="0.0.0.JavaSE_001_008", org.xml.sax.ext; uses:="org.xml.sax,org.xml.sax.helpers"; version="0.0.0.JavaSE_001_008", org.xml.sax.helpers; uses:="org.xml.sax"; version="0.0.0.JavaSE_001_008", java.lang.invoke; version="0.0.0.JavaSE_001_008", java.nio.file; version="0.0.0.JavaSE_001_008", java.nio.file.attribute; version="0.0.0.JavaSE_001_008", java.nio.file.spi; version="0.0.0.JavaSE_001_008", javax.lang.model.element; uses:="javax.lang.model,javax.lang.model.type"; version="0.0.0.JavaSE_001_008", javax.lang.model.type; uses:="javax.lang.model,javax.lang.model.element"; version="0.0.0.JavaSE_001_008", javax.management.monitor; uses:="javax.management"; version="0.0.0.JavaSE_001_008", javax.swing.colorchooser; uses:="javax.accessibility,javax.swing,javax.swing.border,javax.swing.event,javax.swing.text"; version="0.0.0.JavaSE_001_008", javax.swing.plaf.basic; uses:="javax.accessibility,javax.sound.sampled,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.tree"; version="0.0.0.JavaSE_001_008", javax.swing.plaf.nimbus; uses:="javax.swing,javax.swing.border,javax.swing.plaf,javax.swing.plaf.synth"; version="0.0.0.JavaSE_001_008", javax.swing.plaf.synth; uses:="javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.table,javax.swing.text,javax.swing.tree,javax.xml.parsers,org.xml.sax,org.xml.sax.helpers"; version="0.0.0.JavaSE_001_008", javax.xml.ws; uses:="javax.xml.bind,javax.xml.bind.annotation,javax.xml.namespace,javax.xml.transform,javax.xml.transform.stream,javax.xml.ws.handler,javax.xml.ws.spi,javax.xml.ws.spi.http,org.w3c.dom"; version="0.0.0.JavaSE_001_008", javax.xml.ws.spi.http; version="0.0.0.JavaSE_001_008", java.time; version="0.0.0.JavaSE_001_008", java.time.chrono; version="0.0.0.JavaSE_001_008", java.time.format; version="0.0.0.JavaSE_001_008", java.time.temporal; version="0.0.0.JavaSE_001_008", java.time.zone; version="0.0.0.JavaSE_001_008", java.util.function; version="0.0.0.JavaSE_001_008", java.util.stream; version="0.0.0.JavaSE_001_008", javax.crypto; uses:="javax.crypto.spec,javax.security.auth"; version="0.0.0.JavaSE_001_008", javax.lang.model; uses:="javax.lang.model.element"; version="0.0.0.JavaSE_001_008"
Export-Service = org.osgi.service.packageadmin.PackageAdmin,org.osgi.service.startlevel.StartLevel,org.osgi.service.url.URLHandlers
Provide-Capability = osgi.service; objectClass:List<String>=org.osgi.service.resolver.Resolver; uses:=org.osgi.service.resolver, osgi.service; objectClass:List<String>=org.osgi.service.startlevel.StartLevel; uses:=org.osgi.service.startlevel, osgi.service; objectClass:List<String>=org.osgi.service.packageadmin.PackageAdmin; uses:=org.osgi.service.packageadmin , osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1,1.2", osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8", osgi.ee; osgi.ee="JavaSE/compact1"; version:List<Version>="1.8", osgi.ee; osgi.ee="JavaSE/compact2"; version:List<Version>="1.8", osgi.ee; osgi.ee="JavaSE/compact3"; version:List<Version>="1.8"

Looks like there is a lot of information associated with a bundle and maybe that’s why people consider bundles to be difficult to build. But most of that information is optional. In part 2, we’ll see that it is really easy to build a (simple) bundle.


  1. An OSGi bundle is actually only a module. It can be a component if it fulfills some additional constraints. However, as OSGi also provides support for components, OSGi is often presented as a component framework rather than a module framework. The tons of introductions that focus on a runtime environment such as Felix emphasize that angle. I stumbled upon OSGi while searching for a component framework myself, and if you are still reading this, chances are high that you you are also thinking about components, so let’s stick to that view for the first parts of this introduction.