Skip to main content

Posts

Showing posts from November, 2018

OSGi Deep Dive: Understanding BundleActivator Interface (Part 2)

Hello All! We dived into the basic concepts of OSGi in my previous post. Today we are going to look into more details and will work with the org.osgi.framework.BundleActivator interface.

We know that in OSGi, all service implementations are packaged into bundles. We can make a bundle lifecycle-aware by including a bundle activator to manage the lifecycle of the bundle. A bundle activator is nothing but a Java class that implements org.osgi.framework.BundleActivator interface and it is instantiated when a bundle is started.

In other words, a bundle gets the access of OSGi framework using a unique instance of BundleContext. But to get this unique instance, the class must implement the BundleActivator interface.

This interface has two methods start(BundleContext context) and stop(BundleContext context) and they are called when the bundle is started or stopped respectively.
Creating a Simple Bundle Now, we will see the concepts in action via some code. We are going to create a bundle tha…