OSGi:
Eclipse IDE is one of the extensively used Java development tool and I have been using it from the start of my Java programming career. One of the key features of Eclipse which impresses me a lot is its plugin architecture. To add support for a new feature we just download the relevant plugins, copy them to the plugins folder and after a restart all the required menus are in place and all the new features are available at our disposal.
I always wanted to develop an application on a similar architecture but due to other project priorities couldn’t research a lot on this. After 7 years of my S/W career I was finally struck with an opportunity to develop an application based on the OSGi Framework. As I started my research on OSGi framework I realized this is what I had been waiting for a long time.
What is OSGi?
From my initial discussions you must have got a clue that OSGi development is somewhere related to plugin development. Correct OSGi framework allows us to build highly modular Java applications composed of small components.
To define it more correctly the OSGi Framework provides the standardized specifications that allow applications to be constructed from small, reusable and collaborative components. These components are highly cohesive and loosely coupled. Each component can be individually developed, tested, deployed, updated and managed with minimal or impact on other components.The components can be composed into an application and deployed.
OSGi Bundles
An application module or component is termed as a bundle in OSGi. Bundles are the common Java jar files except that their Manifest file contains more OSGi specific details like a definitive name, version, dependencies and other deployment details.
As opposed to normal Java application which is packaged in a monolithic jar/war file bundles are logical modules that combines to comprise an application. They explicitly define which packages they export and which external packages they depend upon. OSGi framework performs bundle resolution ensuring consistency among bundles with respects to their versions and other constraints.
The OSGi specification defines a life cycle for OSGi bundles and once the bundle is deployed the bundle life cycle determines its status. A bundle can be installed, started, stopped and uninstalled from the framework following the lifecycle prescribed by the OSGi specifications.
OSGi Containers
OSGi based application run within an OSGi Container. Following are some of the popular OSGi containers:
OSGi Benefits
In this article I touched upon what is OSGi and what benefits it offers. In the next article I would like to touch upon the challenges in developing an OSGi based application and how Spring DM server comes to the rescue.
Following are some of the good reference books for starting with OSGi