@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { // Check whether this is an OSGi deployment or whether it wants to have an OSGi type injected DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); Deployment deployment = depUnit.getAttachment(OSGiConstants.DEPLOYMENT_KEY); boolean hasInjectionPoint = hasValidInjectionPoint(depUnit); if (deployment == null && hasInjectionPoint == false) return; // Activate the framework if not done so already FrameworkActivator.activate(depUnit.getAttachment(Attachments.SERVICE_VERIFICATION_HANDLER)); // Setup a dependency on the the next phase. Persistent bundles have a dependency on the bootstrap bundles if (deploymentTracker.isComplete()) { phaseContext.addDeploymentDependency(Services.FRAMEWORK_ACTIVE, AttachmentKey.create(Object.class)); } else { phaseContext.addDeploymentDependency(MODULE_REGISTRATION_COMPLETE, AttachmentKey.create(Object.class)); phaseContext.addDeploymentDependency(Services.FRAMEWORK_CREATE, OSGiConstants.SYSTEM_CONTEXT_KEY); } // Make these services available for a bundle deployment only phaseContext.addDeploymentDependency(Services.BUNDLE_MANAGER, OSGiConstants.BUNDLE_MANAGER_KEY); phaseContext.addDeploymentDependency(Services.RESOLVER, OSGiConstants.RESOLVER_KEY); phaseContext.addDeploymentDependency(Services.ENVIRONMENT, OSGiConstants.ENVIRONMENT_KEY); }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { // Check whether this is an OSGi deployment or whether it wants to have an OSGi type injected DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); Deployment deployment = depUnit.getAttachment(OSGiConstants.DEPLOYMENT_KEY); boolean hasInjectionPoint = hasValidInjectionPoint(depUnit); if (deployment == null && hasInjectionPoint == false) return; // Activate the framework if not done so already FrameworkActivator.activate(depUnit.getAttachment(Attachments.SERVICE_VERIFICATION_HANDLER)); // Setup a dependency on the the next phase. Persistent bundles have a dependency on the bootstrap bundles if (deploymentTracker.isComplete()) { phaseContext.addDeploymentDependency(Services.FRAMEWORK_ACTIVE, AttachmentKey.create(Object.class)); } else { phaseContext.addDeploymentDependency(MODULE_REGISTRATION_COMPLETE, AttachmentKey.create(Object.class)); } // Make these services available for a bundle deployment only phaseContext.addDeploymentDependency(Services.FRAMEWORK_CREATE, OSGiConstants.SYSTEM_CONTEXT_KEY); phaseContext.addDeploymentDependency(Services.BUNDLE_MANAGER, OSGiConstants.BUNDLE_MANAGER_KEY); phaseContext.addDeploymentDependency(Services.RESOLVER, OSGiConstants.RESOLVER_KEY); phaseContext.addDeploymentDependency(Services.ENVIRONMENT, OSGiConstants.ENVIRONMENT_KEY); }