Gaurav Purandare wrote:Few people do not have a good experience working with OSGi for larger projects, with too many layers and too many dependencies
it becomes bit of a hassle trying to figure out the exceptions.
If using OSGi is worth it, with too many knobs and too many levers, would it be useful to convert existing applications to OSGi?
First, I do not necessarily think that OSGi is some golden hammer that must be used on every application. An ounce of pragmatism is in order to decide whether OSGi is a proper fit.
But, I'm not sure I follow your "too many layers and too many dependencies" statement? Are you talking about OSGi or the application you'd consider converting to OSGi? If you're referring to OSGi, then I think you may be mistaken about the supposed complexity of OSGi. The core OSGi specification defines a very small API with only a handful of packages and mostly interfaces with one or two method requirements. Even then, if you develop to the OSGi API, you'll likely only ever use a handful of those interfaces. And, even then, you'd be better off using a declarative OSGi model such as Spring-DM. With Spring-DM, OSGi isn't much harder than wiring beans.
Again, even though I don't follow the "too many knobs and too many levers" argument, I can only answer your final question with a 2-word answer: It depends.
I don't know anything about the application that you'd consider converting. Most applications would benefit from OSGi...but there may be some valid reasons (either technical or non-technical) that might make me decide to leave OSGi out. It depends.
But, should you decide to convert an existing application, be aware that it's very possible to take it piece-meal. You don't have to convert it all in one fell swoop. I have some decent notes on how to do such a conversion and hope to blog about them soon. But if you have any specific questions on converting that I can help you with, please feel free to ask.
I think I know what Gaurav is worrying about! I had a similiar impression when I used the NetBeans platform the first time for a more or less big project.
As we discussed in another post NetBeans has a module system which is quite similar to OSGi. At first I thought that the module system would constrain my application design. Only after thinking about modules and a well-structured application architecture I started to realize that it was not the module system which felt a little bit strange - it was my application design itself what was the problem!
If you take the time to clearly define modules and their dependencies it will definitely be worth the effort and pay off later with any changes you have to make to an application. A good modular architecture with clear dependencies etc. is not always easy to achieve but from my own experience I can tell you that a module system like NetBeans or OSGi will encourage you to get to a better application design which is particularly important if you have to maintain or extend an application later.
I hope this could clear your doubts a little bit ;-)
Joined: Sep 19, 2003
Another way of thinking of it is to compare OSGi with JUnit (yes...I know...obscure comparison, but hear me out).
Every time I write JUnit test, I constrain my code. I create constraints that don't let me do things I shouldn't do. But do I ditch JUnit because it's constraining? No...those constraints are a good thing and I want them there to keep me from driving my app off a cliff.
Same with OSGi. It does constrain you a little bit. But that's okay, because those constraints are there to help you build truly modular applications, something that is very difficult to accomplish on your own.