The advantages of OSGi is that it gives you runtime support for modularity. This allows you to do things like enforcing module relationships at runtime, deploy different versions of a module alongside each other, hot deploy modules to a running application, and enforce module encapsulation. These are all things that standard Java cannot do. At the end of Chapter 3 (download link for this chapter available below), I provide an example that demonstrates how you cannot enforce module encapsulation using standard Java. Then, I show how you can enforce module encapsulation using OSGi. Personally, it's one of my favorite examples. Other favorites of mine include the reference implementation in Chapter 7, the Manage Relationships sample code (inverting and eliminating relationships), the Acyclic Relationships sample code (escalation, demotion, callback)...Ok...I like several of the examples, including Part 3 where I show how to take a system that's designed using the patterns and port it to OSGi. It was just so easy to do and you realize the benefits immediately.
In general, runtime support for modularity makes it easier to design modular software since the runtime container enforces your design time constructs. To design modular software without a runtime container, you have to employ other tools (i.e., JarAnalyzer in the book) and techniques (i.e., Levelize Build) to enforce modularity. I'd argue that if you don't already have a modular application, you should focus your efforts on modularizing the application first. Then, start using OSGi. Using OSGi if you don't have a modular application won't provide you all the benefits OSGi offers.
Visit the book's website at modularity.kirkk.com where you can review all 18 patterns and download an excerpt of the book. There is also a mobile web application available that you can take with you wherever you go.
Joined: Apr 23, 2008
Thank you, Kirk.
Those all things are very interesting and you have awakened my curiosity about OSGi and what it can provide to my job.