felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From charbel elkaed <charbel.k...@gmail.com>
Subject Clean way to stop a Bundle from inside
Date Fri, 11 Feb 2011 12:40:19 GMT
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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message