Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » *SOLVED* OSGi 'update' command with services(OSGi update, declarative services, unexpected behavior.)
icon7.gif  *SOLVED* OSGi 'update' command with services [message #1075194] Sun, 28 July 2013 21:38 Go to next message
Aaron Skelsey is currently offline Aaron Skelsey
Messages: 4
Registered: July 2013
Junior Member

Solution to problem is in reply

Hi All,

I've got an OSGi specific problem and was not sure where to post, so I thought here might be a good start and maybe someone can nudge me in the right direction?

My end goal: I'm trying to implement a platform that can dynamically update bundles using OSGi.

So far: I've made 2 bundles; a math bundle (has 2 methods that can add and multiply) and a display bundle which has a thread which runs every second, generates 2 random numbers and uses the previously mentioned math bundle to add them and multiply them (and display the result).
I'm using declarative services and as such have a component definition in the math bundle that exports a service defined by the interface IMath. Equally I have a component definition in the display bundle that subscribes (1:1 static) to a service defined by the IMath interface. I've got typical debug messages on each stage of startup / shutdown of each component.

When the project starts up I'd typically see:
Quote:

Starting up Math...
Starting up Display...
Running the Display thread...

then every second I will see the display thread doing calculations. In addition I can do the following (assuming math is bundle 1 and display is bundle 2).
Quote:

stop 1
Stopping the Display thread...
Display bundle has been shut down.
Math bundle has been shut down
start 1
Starting up Math...
Starting up Display...
Running the Display thread...


The problem: So far so good right? Everything is going great until I try to use the 'update' command. In this case I want to update the math bundle as I made an error in the multiply calculation.
Quote:

update 1
Stopping the Display thread...
Display bundle has been shut down.
Math bundle has been shut down
Starting up Math...

What the? why didn't ds call my startup method to restart the display bundle? I also tried updating the display bundle and it seems to work fine. I get the feeling that if you update a bundle it will restart, but any bundles that subscribe to a service from the updated bundle will just sit in limbo.
To make things worse if I stop and start the display bundle it STILL doesn't start up.

I'm fairly sure that I'm looking at something the wrong way, so it would be nice if someone could shed some light on my problem. If someone wants source code let me know and I can attach some basic java files to demonstrate the problem.

Thanks for reading!
Aaron

[Updated on: Mon, 29 July 2013 19:24]

Report message to a moderator

Re: OSGi 'update' command with services [message #1075711 is a reply to message #1075194] Mon, 29 July 2013 19:23 Go to previous message
Aaron Skelsey is currently offline Aaron Skelsey
Messages: 4
Registered: July 2013
Junior Member
Hi All,

I managed to get a really good explanation from Peter Kriens on StackOverflow(I'm not allowed to post a link, so look at the end of the post for the URL); this guy really know a lot about OSGi!

To summarize:
When you update a bundle, all the wiring (e.g. dynamic services) that you had between your old upgraded bundle and other bundles are left. This means that all these links go stale; the service management doesn't automatically join your old bundles to the newly updated one.

To make everyone happy again you can use the refresh command in the OSGi console, or if you want to do it from code you can use the FrameworkWiring.refreshBundles() method.

If anyone wants more information let me know and I can post a more detailed message with code snippets.

I hope this has cleared up any problems other people may have when using the update functionality in OSGi.

Have a great day!

* URL to StackOverflow detailed response from Peter Kriens :
http://
stackoverflow.com/questions/17917633/osgi-update-command-dynamic-services-wont-restart
Previous Topic:How to deploy Sessionless EJB in TOMEE
Next Topic:Get eclipse to re-install the android SDK
Goto Forum:
  


Current Time: Thu Jul 31 11:33:52 EDT 2014

Powered by FUDForum. Page generated in 0.02460 seconds