/** * @param osgiDeployable The OSGi deployable * @param bundle Its associated Bundle to start */ protected void startBundle(OSGiDeployable osgiDeployable, Bundle bundle) { if (osgiDeployable.isStart()) { try { // Compute the options // Always respect the bundle's activation policy int options = Bundle.START_ACTIVATION_POLICY; // Enable transient bundle if required if (osgiDeployable.isStartTransient()) { options |= Bundle.START_TRANSIENT; } // Start the bundle with the options bundle.start(options); } catch (BundleException e) { logger.error("Cannot start the bundle ''{0}''.", osgiDeployable, e); } } }
/** * 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; }
try { Boolean start = DeploymentHelper.isStart(fragment); OSGiDeployable.class.cast(deployable).setStart(start); Boolean reference = DeploymentHelper.isReference(fragment); OSGiDeployable.class.cast(deployable).setReference(reference); Integer startLevel = DeploymentHelper.getStartLevel(fragment); OSGiDeployable.class.cast(deployable).setStartLevel(startLevel); Boolean startTransient = DeploymentHelper.isStartTransient(fragment); OSGiDeployable.class.cast(deployable).setStartTransient(startTransient); } catch (InvalidDeploymentException e) { throw new FragmentDeploymentException("Invalid deployment found : " + fragment, e);
/** * 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; }
/** * @param osgiDeployable The OSGi deployable * @param bundle Its associated Bundle to start */ protected void startBundle(OSGiDeployable osgiDeployable, Bundle bundle) { if (osgiDeployable.isStart()) { try { // Compute the options // Always respect the bundle's activation policy int options = Bundle.START_ACTIVATION_POLICY; // Enable transient bundle if required if (osgiDeployable.isStartTransient()) { options |= Bundle.START_TRANSIENT; } // Start the bundle with the options bundle.start(options); } catch (BundleException e) { logger.error("Cannot start the bundle ''{0}''.", osgiDeployable, e); } } }