I'm developing an OSGi based system that I intend to periodically 'update' without bringing down the whole system. I am intending on using 'update' to facilitate bundle changes and as such wrote a small app (2 bundles) to try to prove the theory.
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:
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).
> 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.
> 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.
If I haven't been specific enough about my problem please let me know and I'll extrapolate.
Thanks for reading! Aaron