Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Replacing OSGI bundles in the running environment
Replacing OSGI bundles in the running environment [message #834901] Mon, 02 April 2012 14:36 Go to next message
Piotrek De is currently offline Piotrek De
Messages: 5
Registered: March 2012
Junior Member
Hi,

I have split my application into several OSGI bundles and one OSGIfied WAR.
Some of my bundles depends on others in a meaning that they import packages exported by other bundles. Exactly the same is with my WAR - it imports some packages exported by other my bundles. So far everything works fine - bundles must be deployed to virgo in a specific order so that dependencies are satisfied and my WAR works as expected.

What I'm trying to achieve is to replace some bundle in the running environment. Let's say that my WAR imports packages from bundles A,B,C and application works on production Virgo server. When QA reports bug and it affects only module A, I'd like to be able to replace only module A, having all other system components running unaffected. (With standard approach, I'd have to redeploy entire application - WAR along with all its JARs embedded - it causes that for some time my server does not respond).

Is it possible with OSGI?

With my current configuration, with all bundles and WAR in the "ACTIVE" state, when I stop bundle "A", it changes its state to "RESOLVED". I can also uninstall this bundle, and install it again. During all these operations, entire system works fine (WAR responds for requests). But when the actual reload/upgrade of classes takes place? My WAR is based on Spring framework, so all instances are available in container. Thus, probably, they will never get upgraded, until I'll restart the container/WAR. Is that true? Are there any other approaches to achieve what I want to do?

Thanks in advance for any hints!

[Updated on: Mon, 02 April 2012 14:44]

Report message to a moderator

Re: Replacing OSGI bundles in the running environment [message #834920 is a reply to message #834901] Mon, 02 April 2012 14:54 Go to previous message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
When you import a package in OSGi, you create a dependency from the importing bundle, let's call it A, to the exporting bundle, let's call it B. If you update the exporting bundle and then refresh, the importing bundle will be stopped and re-started.

The way to soften the dependency is to use services and put the service interfaces in a separate bundle, C, that rarely needs updating. Then you can import the package containing the service interfaces into both A and B. That cuts the package dependency from A to B and so you can now update B and refresh without directly impacting A. However, there is a further step because updating B involves stopping the bundle and restarting it, which will bring down the services published by B. But if you use Spring DM (or Blueprint) to express the service reference in bundle A, then you'll get a proxy created which can cope with the service going away and coming back later. You should then be able to update B and refresh without forcing A to restart.

P.S. To be precise you have a Web Application Bundle (WAB), since adding an Import-Package statement to a WAR turns it into a WAB. Read the OSGi Enterprise spec for details of Web Application Bundles.
Previous Topic:Context Path issue with WAB
Next Topic:Spring ORM Bundle - ClassNotFoundException
Goto Forum:
  


Current Time: Sun Oct 26 04:33:30 GMT 2014

Powered by FUDForum. Page generated in 0.02411 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software