3 Replies Latest reply on Jun 4, 2010 7:20 AM by bosschaert

    Where does OSGiBundleManager.stopBundle() emit BundleEvent.STOPPED?

    bosschaert

      In relation to the Start Level Service TCK I am trying to get the following testcase passing:

      The test starts a bundle. In the BundleActivator.start() of that bundle it calls a method on the Start Level Service, which under the hood causes the the bundle to be stopped. This potentially happens concurrently, so it's not defined whether the Activator.start() finishes before the bundle is actually stopped or not.

       

      To simplify the test behaviour, I've taken the concurrency out of the picture for the moment. So in my setup, the bundle is actually stopped before BundleActivator.start() is finished.

       

      The TCK test has registered an event listener and expects BundleEvent.STARTED and BundleEvent.STOPPED events. However it never receives the STOPPED event (it does get the STARTED event).

       

      I ended up looking at the OSGiBundleManager.stopBundle() method where the real logic seems to be encapsulated in the following 3 lines:

      {code:java}DeploymentUnit unit = bundleState.getDeploymentUnit();
      deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
      deployerClient.checkComplete(unit.getName());{code}

       

      I don't quite follow how these would stop the bundle and, additionally, where the BundleEvent.STOPPED normally comes from.
      Anyone an idea?