How do I start a bundle deployed in AS?
thomas.diesler Oct 13, 2010 8:11 AMDavid 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.