OSGi - Add dynamic modularity to your Java applications

 Comments

Ever imagined, how the Plug and Play (PnP) devices have eased the way we use our electronic devices, especially our PCs and laptops? You purchase a TV tuner card (or any of your other favorite card), plug it into your PC's PCI/PCMCIA slot, and ... Viola! Your PC can now act as a TV! Now your expansion card has added the functionalities of a TV to your PC. You remove the card, and back - your PC has lost its functionality of the TV. To whichever PC, you plug this card in, it just adds the TV functionality!

Mmm! I am not going to talk on those expansion cards. But just imagine if we could get such a functionality in our Java applications. You develop modules similar to the TV tuner card, that you plug in, and your application will gain that additional functionality ... essentially modular!

And now imagine those "hot-swappable" capabilities - you plug in your USB web camera even while your PC is running, take a snap, plug it out- thats it!. Hmm... impressive! Can we get such functionality in Java Applications - add are remove modules on the fly - without restarts? The answer is a big YES! OSGi makes this possible.

What is OSGi?

OSGi stands for Open Services Gateway initiative. This doesn't pretty much explain about what it does. This abbreviation is a thing of the past, and the OSGi Alliance itself is trying to forget it. Now officially, its just a trademark with no special meaning. The shortest description given about OSGi is "Universal Middleware". Software that you write once and then can use in binary form universally: in many different platforms, many different industries, and for many different purposes.


The OSGi Environment
(from the article "The last mile of software deployment" at http://www.aqute.biz/resources/2002/lastmile.pdf)


OSGi is a component-based platform for developing applications in Java. The OSGi site describes it as "dynamic module system for Java". The official definition of OSGi (in its R4 Specifiations) describes OSGi as follows:
The OSGi Service Platform specification delivers an open, common architecture for service providers, developers, software vendors, gateway operators and equipment vendors to develop, deploy and manage services in a coordinated fashion. It enables an entirely new category of smart devices due to its flexible and managed deployment of services. OSGi specifications target settop boxes, service gateways, cable modems, consumer electronics, PCs, industrial computers, cars, mobile phones, and more. Devices that implement the OSGi specifications will enable service providers like telcos, cable operators, utilities, and others to deliver differentiated and valuable services over their networks.

Okay, enough! Its impressive! But, I am not going into its technical details now. You could just go to the references stated, especaially [1], and of course the OSGi R4.1 specifications.

Why OSGi?

OSGi is there to stay. Many industry players have already embraced it. It offers many advantages to faster development, component reuse, easy integration, and other runtime benefits. Adrian Colyer, CEO of SpringSource has written an excellent blog at [8] on why one should consider OSGi framework for the Java Development.

Apart from the benefits mentioned before, an important consideration for choosing up a framework would be its industry acceptance. OSGi is being adopted by almost all the major players of the industry. Its not just the hype, because OSGi has been there now for about a decade. OSGi came out with its initial R1 specifications back in 1998.

Any real world success stories?

Yes of course! Eclipse is just an excellent example of a successful system running on the dynamics of OSGi. From Eclipse version 3.0 onwards,eclipse is backed by the OSGi framework - Equinox (an OSGi framework implementation). In fact, equinox is one of the widely used and fully compliant OSGi framework implementation.

There are other success stories as well, but I am very lazy to write on them! Okey, you can find some here: http://www.mbeddedserver.com/partners/success_stories.html, and here: http://www.infoq.com/news/2008/01/osgi-success.

The OSGi Service Platform is a set of specifications that define an application model inside a VM. You can think of OSGi like a SOA (Service Oriented Architecture) inside a VM (Some even think beyond!). Inside a running VM, it is possible to install, start, stop, update and un-install applications. The VM never has to be stopped. The specifications have a very flexible and powerful management model that made it possible to use the specifications almost as is in Eclipse.

Equinox powers the dynamics of the Eclipse that enables it to have plugins and extensions to provide so many variety of features. You can find eclipse plugins for almost anything. But, one may argue that even systems like the Firefox allows plugin models without OSGi. Right! but the main point is integration and reusing the wheel. Will Firefox(or other model) support the mechanism as a platform that can be used to build your applications? OSGi already is build up as a framework that will support dynamism and plugin model. The plugins (bundles) will be ought to be coherent when the different components integrate, someting that is enforced by the OSGi framework.

A component bundle once tested is bound to work even in the integrated scenario. Of-course, OSGi is not the only answer, you can roll your own, or get others like the JBoss Microcontainer. But OSGi is already mature enough to support applications rangng from mobile applications to enterprise applications. SpringSource has already built an application server on top of OSGi (See [7]).

Now, if one could point at the failures of eclipse, with plugins, or why it needs a restarts and all, the answer is not simple. OSGi framework is good enough, but eclipse had been shifted to this platform, its evolving. It has to support hundreds of plugin developers. And frankly, eclipse is still not able to fully leverage the platform to its full. But from ground-up, if one could consider writing applications on OSGi, it would be worth investing some of your thoughts.
You can know more about OSGi and Eclipse at references [5] and [6].

Conclusion

As you could guess,... I am not that good at blogging. With this blog, I just want to emphasise that - OSGi is there and its happenning. No indepths of OSGi (Its already there written by some great authors, that I have reffered to at the end of this blog).

OSGi has evolved over the past decade, but it still requires a decent grabbing out. It has all the promises, lots of big players also into play. So if you are among those early adopters, you can definitely have a competitive advantage in building modular applications for a long run. So, if you are planning for a new project, all modular and dynamic, take time to think and invest some time for OSGi before rolling out your own solutions.

Whats Next?

In my coming blogs, I will be trying to give out a heads up with using OSGi, using it for the Web and tools that will help you to develop on OSGi.

References

0. http://www.osgi.org/Main/HomePage
1. http://www.osgi.org/About/Technology?section=2 = The OSGi Technical Overview written for the OSGi Alliance
2. http://www.aqute.biz/OSGi/Articles
3. http://www.aqute.biz/OSGi/Presentations
4. http://www.aqute.biz/OSGi/Resources
5. http://www.aqute.biz/OSGi/Eclipse
6. http://www.eclipse.org/equinox/
7. http://www.springsource.com/products/suite/applicationplatform
8. http://blog.springsource.com/main/2008/05/15/why-should-i-care-about-osgi-anyway/
9. http://www.osgi.org/blog/2006/03/eclipsecon-2006-osgi-on-rise.html
10.http://soa.sys-con.com/node/492519
11.http://soa.sys-con.com/node/577046
12.http://www.redmonk.com/jgovernor/2008/02/05/osgi-and-the-rise-of-the-stackless-stack-just-in-time/


JAVA OSGI
blog comments powered by Disqus