File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Why OSGi (Pros and Cons)? What patterns? JAA book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Why OSGi (Pros and Cons)? What patterns? JAA book" Watch "Why OSGi (Pros and Cons)? What patterns? JAA book" New topic

Why OSGi (Pros and Cons)? What patterns? JAA book

Marco Antonio
Ranch Hand

Joined: Apr 23, 2008
Posts: 81
Hi everybody, but specially to Kirk!

In your opinion, why should we design following the OSGi specifications? Which are the advantages to use OSGi? What about the disadvantages? What are the patterns you review in the book?

Thank you so much, and good luck with the book!!!

Any correction of my English will be gratefully accepted.
Kirk Knoernschild
Ranch Hand

Joined: Apr 16, 2012
Posts: 41
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 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.

Twitter: @pragkirk
Marco Antonio
Ranch Hand

Joined: Apr 23, 2008
Posts: 81
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.

Thank you so much!!!
I agree. Here's the link:
subject: Why OSGi (Pros and Cons)? What patterns? JAA book
jQuery in Action, 3rd edition