I'm not sure what you are trying to achieve, but you cannot stop a
bundle from its BundleActivator.stop() method, since that method is only
called when the bundle is being stopped.
Having a bundle stop itself is generally not a good idea and is a little
tricky. I think Peter Kriens did a blog on this, which gives you some
pointers (e.g., use a separate thread, etc.), so look for it.
-> richard
On 2/11/11 7:40, charbel elkaed wrote:
Hi,
I would like to know what is the proper way to stop a bundle from inside the
code?
I implemented bundle having a controller which listens to a service A.
I would like to stop the bundle from inside when the service A leaves.
I want to have the bundle in a resolved state so I can start it later from
another bundle
I tried two ways:
1-
public void stop(BundleContext context) throws Exception {
serviceRegistration.unregister();
context.removeServiceListener(this);}
But then when I list the bundle list ("ps"), the bundle is still in an
Active State and not Resolved
2-
public void stop(BundleContext context) throws Exception {
this.Ctxt.getBundle().stop(); }
But then when I list the bundle list ("ps"), the bundle is in an resolved
State but I have the following trace of exception
*ERROR: Error stopping bundle. (org.osgi.framework.BundleException: Bundle
auto.generated.sendps [48] cannot be stopped since it is already stopping.)
org.osgi.framework.BundleException: Bundle auto.generated.sendps [48] cannot
be stopped since it is already stopping.
at org.apache.felix.framework.Felix.stopBundle(Felix.java:2120)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:941)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:928)
at auto.generated.sendps.Activator.stop(Activator.java:125)
at
org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:655)
at org.apache.felix.framework.Felix.stopBundle(Felix.java:2190)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:941)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:928)
at auto.generated.sendps.Activator.stop(Activator.java:125)
at
auto.generated.sendps.Activator.serviceChanged(Activator.java:157)
at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:864)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:732)
at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
at
org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3726)
at org.apache.felix.framework.Felix.access$000(Felix.java:80)
at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:717)
at
org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:135)
at
org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:129)
at
org.soa4d.osgi.dpws.samples.impl.sends.SendsServer.deactivate(SendsServer.java:210)
at
org.soa4d.osgi.dpws.samples.impl.sends.SendsServer.stop(SendsServer.java:102)
at
org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:655)
at org.apache.felix.framework.Felix.stopBundle(Felix.java:2190)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:941)
at
org.apache.felix.shell.impl.StopCommandImpl.execute(StopCommandImpl.java:93)
at
org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:286)
at org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(A*
ctivator.java:184)
Regards,
Charbel.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]