-
1. Re: Is there a general way to implement stopping a bundle?
ffang Mar 19, 2013 9:12 PM (in response to wl880504)Hi,
You can use bundle Activator instead.
In the Activator start method, you can start a thread to run the controller, and in the Activator stop method, you can do some cleanup job(like end the thread you started).
Never use System.exit(0) in OSGi container, as it will terminate whole process
Freeman
-
2. Re: Is there a general way to implement stopping a bundle?
wl880504 Mar 22, 2013 8:27 PM (in response to ffang)Hi Freeman,
I just realize that the problem is not only about the controller.run method. Before controller.run() is executed, many threads are already invoked using ScheduledExecutorService.
I want to know how to stop the process with multiple running threads in osgi. Like in command line, I can use Ctrl + c to stop the floodlight process.
-
3. Re: Is there a general way to implement stopping a bundle?
ffang Mar 24, 2013 9:45 PM (in response to wl880504)As I already mentioned, you can have an OSGi activator appended to your bundle, where you can do any cleanup job in stop method in that activator, so when you use osgi:stop your_bundle_id, the stop method in that activator get invoked, that provide a graceful way to shutdown your bundle.
I really can't understand why you wanna kill whole process when shutdown a single bundle.
OSGi container is a process basically, you can install any bundles in this container, and manage the bundle's lifecycle gracefully.
Freeman
-
4. Re: Is there a general way to implement stopping a bundle?
wl880504 Mar 25, 2013 2:56 PM (in response to ffang)I will make it clearer. Floodlight is an existing java project. My research is to move it to OSGi container and do some work. It is developed as a multi-thread project and it does not provide any stop methods to stop it. Most of the threads runs forever once get started.
It is kind of a big project and right now I am not familiar with how it implements multiple threads. Thus the problem is that I do not know how to implement specific cleanup job to stop it by myself.
So I am wondering if OSGi provides any mechanism to help find and stop these threads.