@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); final Deployment deployment = depUnit.getAttachment(OSGiConstants.DEPLOYMENT_KEY); if (deployment == null) return; try { BundleManager bundleManager = depUnit.getAttachment(OSGiConstants.BUNDLE_MANAGER_KEY); BundleContext syscontext = depUnit.getAttachment(OSGiConstants.SYSTEM_CONTEXT_KEY); if (deploymentTracker.hasDeploymentName(depUnit.getName())) { restoreStorageState(phaseContext, deployment); } XBundleRevision brev = bundleManager.createBundleRevision(syscontext, deployment, phaseContext.getServiceTarget()); depUnit.putAttachment(OSGiConstants.BUNDLE_REVISION_KEY, brev); depUnit.putAttachment(BUNDLE_STATE_KEY, BundleState.INSTALLED); } catch (BundleException ex) { throw new DeploymentUnitProcessingException(ex); } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); final Deployment deployment = depUnit.getAttachment(OSGiConstants.DEPLOYMENT_KEY); if (deployment == null) return; ServiceName serviceName; try { final BundleManager bundleManager = depUnit.getAttachment(OSGiConstants.BUNDLE_MANAGER_KEY); if (deploymentTracker.hasDeploymentName(depUnit.getName())) { restoreStorageState(phaseContext, deployment); } serviceName = bundleManager.installBundle(deployment, phaseContext.getServiceTarget(), null); } catch (BundleException ex) { throw new DeploymentUnitProcessingException(ex); } // Add a dependency on the next phase for this bundle to be installed phaseContext.addDeploymentDependency(serviceName, OSGiConstants.BUNDLE_KEY); depUnit.putAttachment(BUNDLE_STATE_KEY, BundleState.INSTALLED); depUnit.putAttachment(BUNDLE_INSTALL_SERVICE, serviceName); }