@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); OSGiMetaData metadata = depUnit.getAttachment(OSGiConstants.OSGI_METADATA_KEY); if (metadata == null || metadata.getBundleActivator() == null) return; String componentClass = metadata.getBundleActivator(); String componentName = BundleActivator.class.getSimpleName(); EEModuleDescription moduleDescription = depUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); if (moduleDescription != null) { ComponentDescription componentDescription = new ComponentDescription(componentName, componentClass, moduleDescription, depUnit.getServiceName()); moduleDescription.addComponent(componentDescription); } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); OSGiMetaData metadata = depUnit.getAttachment(OSGiConstants.OSGI_METADATA_KEY); if (metadata == null || metadata.getBundleActivator() == null) return; String componentClass = metadata.getBundleActivator(); String componentName = BundleActivator.class.getSimpleName(); EEModuleDescription moduleDescription = depUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); if (moduleDescription != null) { ComponentDescription componentDescription = new ComponentDescription(componentName, componentClass, moduleDescription, depUnit.getServiceName()); moduleDescription.addComponent(componentDescription); } }
static ServiceController<XBundle> addService(ServiceTarget serviceTarget, DeploymentUnit depUnit, XBundle bundle) { BundleManager bundleManager = depUnit.getAttachment(OSGiConstants.BUNDLE_MANAGER_KEY); ServiceName resolvedBundle = bundleManager.getServiceName(bundle, Bundle.RESOLVED); ServiceName serviceName = depUnit.getServiceName().append("Activate"); BundleActivateService service = new BundleActivateService(depUnit); ServiceBuilder<XBundle> builder = serviceTarget.addService(serviceName, service); builder.addDependency(resolvedBundle, XBundle.class, service.injectedBundle); // Add a dependency on the BundleActivator component OSGiMetaData metadata = depUnit.getAttachment(OSGiConstants.OSGI_METADATA_KEY); if (metadata != null && metadata.getBundleActivator() != null) { String activatorClass = metadata.getBundleActivator(); EEModuleDescription moduleDescription = depUnit.getAttachment(EE_MODULE_DESCRIPTION); for (ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) { if (activatorClass.equals(componentDescription.getComponentClassName())) { ServiceName startServiceName = componentDescription.getStartServiceName(); builder.addDependency(startServiceName, Component.class, service.injectedComponent); } } } return builder.install(); }
static ServiceController<XBundle> addService(ServiceTarget serviceTarget, DeploymentUnit depUnit, XBundle bundle) { ServiceName serviceName = depUnit.getServiceName().append("Activate"); BundleActivateService service = new BundleActivateService(depUnit, bundle); ServiceBuilder<XBundle> builder = serviceTarget.addService(serviceName, service); // Add a dependency on the BundleActivator component OSGiMetaData metadata = depUnit.getAttachment(OSGiConstants.OSGI_METADATA_KEY); if (metadata != null && metadata.getBundleActivator() != null) { String activatorClass = metadata.getBundleActivator(); EEModuleDescription moduleDescription = depUnit.getAttachment(EE_MODULE_DESCRIPTION); if (moduleDescription != null) { for (ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) { if (activatorClass.equals(componentDescription.getComponentClassName())) { ServiceName startServiceName = componentDescription.getStartServiceName(); builder.addDependency(startServiceName, Component.class, service.injectedComponent); } } } } // Add other named dependencies builder.addDependencies(depUnit.getAttachmentList(Attachments.BUNDLE_ACTIVE_DEPENDENCIES)); return builder.install(); }