private void installAliases(final ModuleSpecification moduleSpecification, final ModuleIdentifier moduleIdentifier, final DeploymentUnit deploymentUnit, final DeploymentPhaseContext phaseContext) { for (final ModuleIdentifier alias : moduleSpecification.getAliases()) { final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias); final ModuleSpec spec = ModuleSpec.buildAlias(alias, moduleIdentifier).create(); ModuleDefinition moduleDefinition = new ModuleDefinition(alias, new HashSet<>(moduleSpecification.getAllDependencies()), spec); final ValueService<ModuleDefinition> moduleSpecService = new ValueService<>(new ImmediateValue<>(moduleDefinition)); phaseContext.getServiceTarget().addService(moduleSpecServiceName, moduleSpecService).addDependencies( deploymentUnit.getServiceName()).addDependencies(phaseContext.getPhaseServiceName()).setInitialMode( Mode.ON_DEMAND).install(); ModuleLoadService.installService(phaseContext.getServiceTarget(), alias, Collections.singletonList(moduleIdentifier)); ModuleResolvePhaseService.installService(phaseContext.getServiceTarget(), moduleDefinition); } }
private void installAliases(final ModuleSpecification moduleSpecification, final ModuleIdentifier moduleIdentifier, final DeploymentUnit deploymentUnit, final DeploymentPhaseContext phaseContext) { for (final ModuleIdentifier alias : moduleSpecification.getAliases()) { final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias); final ModuleSpec spec = ModuleSpec.buildAlias(alias, moduleIdentifier).create(); final ValueService<ModuleSpec> moduleSpecService = new ValueService<ModuleSpec>(new ImmediateValue<ModuleSpec>(spec)); phaseContext.getServiceTarget().addService(moduleSpecServiceName, moduleSpecService).addDependencies( deploymentUnit.getServiceName()).addDependencies(phaseContext.getPhaseServiceName()).setInitialMode( Mode.ON_DEMAND).install(); ModuleLoadService.installService(phaseContext.getServiceTarget(), alias, Collections.singletonList(moduleIdentifier)); } }
private void installAliases(final ModuleSpecification moduleSpecification, final ModuleIdentifier moduleIdentifier, final DeploymentUnit deploymentUnit, final DeploymentPhaseContext phaseContext) { ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER); for (final ModuleIdentifier alias : moduleSpecification.getAliases()) { final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias); final ModuleSpec spec = ModuleSpec.buildAlias(alias, moduleIdentifier).create(); HashSet<ModuleDependency> dependencies = new HashSet<>(moduleSpecification.getAllDependencies()); //we need to add the module we are aliasing as a dependency, to make sure that it will be resolved dependencies.add(new ModuleDependency(moduleLoader, moduleIdentifier, false, false, false, false)); ModuleDefinition moduleDefinition = new ModuleDefinition(alias, dependencies, spec); final ValueService<ModuleDefinition> moduleSpecService = new ValueService<>(new ImmediateValue<>(moduleDefinition)); final ServiceBuilder sb = phaseContext.getServiceTarget().addService(moduleSpecServiceName, moduleSpecService); sb.requires(deploymentUnit.getServiceName()); sb.requires(phaseContext.getPhaseServiceName()); sb.setInitialMode(Mode.ON_DEMAND); sb.install(); ModuleLoadService.installService(phaseContext.getServiceTarget(), alias, Collections.singletonList(moduleIdentifier)); ModuleResolvePhaseService.installService(phaseContext.getServiceTarget(), moduleDefinition); } }
private void installAliases(final ModuleSpecification moduleSpecification, final ModuleIdentifier moduleIdentifier, final DeploymentUnit deploymentUnit, final DeploymentPhaseContext phaseContext) { ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER); for (final ModuleIdentifier alias : moduleSpecification.getAliases()) { final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias); final ModuleSpec spec = ModuleSpec.buildAlias(alias, moduleIdentifier).create(); HashSet<ModuleDependency> dependencies = new HashSet<>(moduleSpecification.getAllDependencies()); //we need to add the module we are aliasing as a dependency, to make sure that it will be resolved dependencies.add(new ModuleDependency(moduleLoader, moduleIdentifier, false, false, false, false)); ModuleDefinition moduleDefinition = new ModuleDefinition(alias, dependencies, spec); final ValueService<ModuleDefinition> moduleSpecService = new ValueService<>(new ImmediateValue<>(moduleDefinition)); final ServiceBuilder sb = phaseContext.getServiceTarget().addService(moduleSpecServiceName, moduleSpecService); sb.requires(deploymentUnit.getServiceName()); sb.requires(phaseContext.getPhaseServiceName()); sb.setInitialMode(Mode.ON_DEMAND); sb.install(); ModuleLoadService.installService(phaseContext.getServiceTarget(), alias, Collections.singletonList(moduleIdentifier)); ModuleResolvePhaseService.installService(phaseContext.getServiceTarget(), moduleDefinition); } }