2 Replies Latest reply on Oct 13, 2010 4:21 PM by thomas.diesler

    How do I start a bundle deployed in AS?

    thomas.diesler

      David asks:

       

      I can install a bundle by dropping it in the deployments folder but I  don't see it getting started.

      Looking through the code I have 2 questions:
      1. In the org.jboss.as.osgi.deployment.SystemDeployerService I see that  deploy(Deployment) behaves differently than deploy(Deployment []) where  the former doesn't take the autoStart setting into account. Is this a  mistake?

      2. How do I actually set the autostart setting on the deployment?
      I can see that org.jboss.osgi.deployment.internal.AbstractDeployment has  a setAutoStart() but where is it called from?

       

      The start problem is probably related to why the server needs restart. This should be fixed later today.

       

      #1 Yes, that's a bug

       

      #2 It is called by whoever constructs the Deployment. The likely candidate for AS7 hot-deployment OSGiAttachmentsDeploymentProcessor. The static configuration is handled by this code in OSGiFrameworkService

       

                  // Create the list of {@link Deployment}s for the configured modules
                  List<Deployment> deployments = new ArrayList<Deployment>();
                  BundleDeploymentPlugin depPlugin = bundleManager.getPlugin(BundleDeploymentPlugin.class);
                  for (OSGiModule module : injectedConfig.getValue().getModules()) {
                      ModuleIdentifier identifier = module.getIdentifier();
                      Deployment dep = depPlugin.createDeployment(identifier);
                      dep.setAutoStart(module.isStart());
                      deployments.add(dep);
                  }
      
                  // Deploy the bundles through the {@link DeployerService}
                  ServiceReference sref = sysContext.getServiceReference(DeployerService.class.getName());
                  DeployerService service = (DeployerService) sysContext.getService(sref);
                  service.deploy(deployments.toArray(new Deployment[deployments.size()]));
      

       

      It generally needs to be discussed how bundle hot-deployment, with its two stage activation ( i.e. install, start ) is suposed to work in AS. The cheap approach would be to somehow require the user to move (rather than copy) the bundles to the deployments folder. This would probably ensure that all bundles are part of the same scan cycle. Otherwise, I can't yet see how install + start can work when the installed bundles are spread accross multiple scans.

        • 1. Re: How do I start a bundle deployed in AS?
          bosschaert

          Thomas Diesler wrote:

           

          #1 Yes, that's a bug

          Ok - I already wrote some code to fix it. Will contribute soon.

           

          Thomas Diesler wrote:

           

          It generally needs to be discussed how bundle hot-deployment, with its two stage activation ( i.e. install, start ) is suposed to work in AS. The cheap approach would be to somehow require the user to move (rather than copy) the bundles to the deployments folder. This would probably ensure that all bundles are part of the same scan cycle. Otherwise, I can't yet see how install + start can work when the installed bundles are spread accross multiple scans.

          I think the word probably is important here. I would like to be a little more sure than that. You might be doing a large deployment with many bundles where the move is still in progress while the scan has happened. It might be good to extend the scanning such that it can find out that the moving is finished because there is no change between two scans.

           

          But first of all, we need to agree on what the default is for all bundles. I'd say it would be a fair assumption that all bundles are automatically started (except for fragment bundles which can't be started at all). I can't think really of a situation where you don't want to start a bundle at all (but sometimes you need to take start levels into account).

           

          Installing is not an issue. The deployer can install bundles whenever they appear in the deployments directory. But only when the scanner finds that there there is no change in what has been put in the deployments folder between two scans it can assume that all the bundles have been put in place and it can being starting them.

          • 2. Re: How do I start a bundle deployed in AS?
            thomas.diesler

            A workaround that relies on ThreadLocal to handle all (bundle) deployments in a DeploymentPlan (which is constructed from a scan) is in place as part of JBAS-8517. The more general AS7 discussion is here

             

            As always, the jbosgi branch contains the latest stable code base.