/** * Install an OSGi deployable * @param osgiDeployable The OSGi deployable to install * @return the installed bundle if the OSGi deployable has been installed. Return null if the bundle is already * installed. * @throws DeployerException */ protected Bundle installBundle(OSGiDeployable osgiDeployable) throws DeployerException { Bundle osgiBundle; try { String url = getURL(osgiDeployable).toExternalForm(); if (osgiDeployable.isReference()) { url = "reference:".concat(url); } //install the bundle osgiBundle = this.bundleContext.installBundle(url); osgiBundle.adapt(BundleStartLevel.class).setStartLevel(osgiDeployable.getStartLevel()); } catch (BundleException e) { // Check the bundle exception type if (e.getType() == BundleException.DUPLICATE_BUNDLE_ERROR) { logger.warn("Cannot deploy a bundle that is already installed " + osgiDeployable + ". ", e.getMessage()); return null; } else { throw new DeployerException("Cannot install the bundle '" + osgiDeployable + "'.", e); } } return osgiBundle; }
/** * Install an OSGi deployable * @param osgiDeployable The OSGi deployable to install * @return the installed bundle if the OSGi deployable has been installed. Return null if the bundle is already * installed. * @throws org.ow2.util.ee.deploy.api.deployer.DeployerException */ protected Bundle installBundle(OSGiDeployable osgiDeployable) throws DeployerException { Bundle osgiBundle; try { String url = getURL(osgiDeployable).toExternalForm(); if (osgiDeployable.isReference()) { url = "reference:".concat(url); } //install the bundle osgiBundle = this.bundleContext.installBundle(url); osgiBundle.adapt(BundleStartLevel.class).setStartLevel(osgiDeployable.getStartLevel()); } catch (BundleException e) { // Check the bundle exception type if (e.getType() == BundleException.DUPLICATE_BUNDLE_ERROR) { logger.warn("Cannot deploy a bundle that is already installed " + osgiDeployable + ". ", e.getMessage()); return null; } else { throw new DeployerException("Cannot install the bundle '" + osgiDeployable + "'.", e); } } return osgiBundle; }