or simpler throw new RuntimeException();

from the spec:

If the start(BundleContext) method throws an exception, the Framework must mark the bundle as stopped and send out STOPPING and STOPPED events but it must not call the Bundle Activator stop(BundleContext) method. The start method must therefore be careful to clean up
any resources it creates in the start method when it throws an exception.

On 19/10/2016 12:51, Guillaume Nodet wrote:
Try stopping / removing the bundle in another thread.

new Thread(new Runnable() {
     final Bundle bundle = bundleContext.getBundle();
     @Override
     public void run() {
         bundle.stop();
     }
}).start();


2016-10-18 14:35 GMT+02:00 sid19039 <sid19...@gmail.com>:

Hello All,

I have trying to stop a bundle from within itself by invoking stop method
as
following in its Activator's start method:
bundleContext.getBundle().stop();

But post this statement is executed, when i check its state via "lb"
command
on  felix shell, its state is shown as Active.
Then when i try to stop it via stop <bundleid> command, an exception is
thrown that
*org.osgi.framework.BundleException: Stopping a starting or stopping
bundle
is currently not supported.*And then its state is shown as *stopping*

Please someone tell how i can achieve this..

Regards
Siddharth




--
View this message in context: http://apache-felix.18485.x6.
nabble.com/how-can-a-bundle-stop-itself-programmatically-tp5018885.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org

Reply via email to