1

I have a web application with different layers (i.e. ui->services->core). If I have to update one of the layer I have to restart the whole application. So I decided using OSGI to seperate these layers. Then I could update each layer without restarting.

Is this a good idea or is osgi not the right approach?

Max Schmidt
  • 7,377
  • 5
  • 23
  • 29

2 Answers2

4

Well, I could not say if it is the approach, but certainly OSGi is a good approach. As pointed out by kctang in its answer, it has quite a steep learning curve. However, it pays in the end. Your strict modular approach allows you to achieve a separation of concerns that is simply not possible with other frameworks.

Referring to your specific case, I recently read a chapter from OSGi in Depth where they make the point for layer separation in OSGi, with a particular focus on cloud deployment. Summarizing, the Remote Services specification would help you distribute your layers onto multiple machines, which can be a life-saver for enterprise applications. Another interesting book for you would be Enterprise OSGi in Action, however it is currently available only through the Manning Early Access Program.

If I have to be critical, JMX support by Framework implementors is still missing. Not that you cannot manage your updates in other ways (programmatic or not), but that would have been useful. Anyway, this is just to say that OSGi has room for improvement.

Luca Geretti
  • 10,206
  • 7
  • 48
  • 58
3

If the concern is to avoid restarting the entire application during development, then OSGi should not be the first option to look at. Check if things like JRebel/LiveRebel will meet your needs.

While OSGi can achieve things like not needing to restart other bundles/layers - if you do it right - IMHO, it has some learning curve to be able to do it right.

Some further reading:

Community
  • 1
  • 1
kctang
  • 10,894
  • 8
  • 44
  • 63
  • 1
    It should be pointed out that JRebel is not free software. – Luca Geretti Jun 21 '12 at 12:07
  • I agree that dynamic reloading is not the main reason to use OSGi. To be clear, there are HUGE benefits from using OSGi, but dynamic loading is the least of them. The main reason to use it is for modularity, i.e. how do you even know that your application is properly layered? How do you enforce that layering, how do you hide functionality from layers that should not be directly accessing it, etc. However as @kctang points out, if you don't care about modularity then JRebel is a good commercial alternative. – Neil Bartlett Jun 21 '12 at 13:32