diff --git a/server/src/main/java/org/jboss/as/server/deployment/DeploymentListModulesHandler.java b/server/src/main/java/org/jboss/as/server/deployment/DeploymentListModulesHandler.java index b6e23b98048..2817b8b7f72 100644 --- a/server/src/main/java/org/jboss/as/server/deployment/DeploymentListModulesHandler.java +++ b/server/src/main/java/org/jboss/as/server/deployment/DeploymentListModulesHandler.java @@ -74,7 +74,7 @@ public void execute(OperationContext context, ModelNode operation) { moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER); } - final ServiceController moduleLoadServiceController = sr.getService(ServiceModuleLoader.moduleServiceName(moduleIdentifier)); + final ServiceController moduleLoadServiceController = sr.getService(ServiceModuleLoader.moduleServiceName(moduleIdentifier.getName())); final ModuleLoadService moduleLoadService = (ModuleLoadService) moduleLoadServiceController.getService(); final ModelNode result = new ModelNode(); diff --git a/server/src/main/java/org/jboss/as/server/deployment/module/ManifestDependencyProcessor.java b/server/src/main/java/org/jboss/as/server/deployment/module/ManifestDependencyProcessor.java index e7ad03b1c39..ee42c3cf194 100644 --- a/server/src/main/java/org/jboss/as/server/deployment/module/ManifestDependencyProcessor.java +++ b/server/src/main/java/org/jboss/as/server/deployment/module/ManifestDependencyProcessor.java @@ -100,7 +100,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, dependencyId); if(dependencyLoader == deploymentModuleLoader && !additionalModules.contains(dependencyId)) { //additional modules will not be created till much later, a dep on them would fail - phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleServiceName(dependencyId)); + phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleServiceName(dependencyId.getName())); } } diff --git a/server/src/main/java/org/jboss/as/server/deployment/module/ModuleExtensionListProcessor.java b/server/src/main/java/org/jboss/as/server/deployment/module/ModuleExtensionListProcessor.java index 59f82d70b80..2329a124324 100644 --- a/server/src/main/java/org/jboss/as/server/deployment/module/ModuleExtensionListProcessor.java +++ b/server/src/main/java/org/jboss/as/server/deployment/module/ModuleExtensionListProcessor.java @@ -88,7 +88,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true); dependency.addImportFilter(PathFilters.getMetaInfFilter(), true); moduleSpecification.addLocalDependency(dependency); - nextPhaseDeps.add(ServiceModuleLoader.moduleSpecServiceName(extension)); + nextPhaseDeps.add(ServiceModuleLoader.moduleSpecServiceName(extension.getName())); } @@ -107,7 +107,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU if (extension != null) { moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, extension, false, false, true, false)); - nextPhaseDeps.add(ServiceModuleLoader.moduleSpecServiceName(extension)); + nextPhaseDeps.add(ServiceModuleLoader.moduleSpecServiceName(extension.getName())); } else { ServerLogger.DEPLOYMENT_LOGGER.cannotFindExtensionListEntry(entry, resourceRoot); } diff --git a/server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java b/server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java index 9995f6e5a9d..050785b80a1 100644 --- a/server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java +++ b/server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java @@ -123,7 +123,7 @@ private void deployModuleSpec(final DeploymentPhaseContext phaseContext) throws for (final DeploymentUnit subDeployment : deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)) { ModuleIdentifier moduleId = subDeployment.getAttachment(Attachments.MODULE_IDENTIFIER); if (moduleId != null) { - phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleSpecServiceName(moduleId)); + phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleSpecServiceName(moduleId.getName())); } } @@ -260,7 +260,7 @@ private ServiceName createModuleService(final DeploymentPhaseContext phaseContex specBuilder.setClassFileTransformer(delegatingClassTransformer); deploymentUnit.putAttachment(DelegatingClassTransformer.ATTACHMENT_KEY, delegatingClassTransformer); final ModuleSpec moduleSpec = specBuilder.create(); - final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(moduleIdentifier); + final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(moduleIdentifier.getName()); ModuleDefinition moduleDefinition = new ModuleDefinition(moduleIdentifier, new HashSet<>(moduleSpecification.getAllDependencies()), moduleSpec); @@ -282,7 +282,7 @@ private void installAliases(final ModuleSpecification moduleSpecification, final ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER); for (final String aliasName : moduleSpecification.getModuleAliases()) { final ModuleIdentifier alias = ModuleIdentifier.create(aliasName); - final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias); + final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias.getName()); final ModuleSpec spec = ModuleSpec.buildAlias(aliasName, moduleIdentifier.getName()).create(); HashSet dependencies = new HashSet<>(moduleSpecification.getAllDependencies()); diff --git a/server/src/main/java/org/jboss/as/server/deployment/module/descriptor/DeploymentStructureDescriptorParser.java b/server/src/main/java/org/jboss/as/server/deployment/module/descriptor/DeploymentStructureDescriptorParser.java index cd929f646b6..240a2503428 100644 --- a/server/src/main/java/org/jboss/as/server/deployment/module/descriptor/DeploymentStructureDescriptorParser.java +++ b/server/src/main/java/org/jboss/as/server/deployment/module/descriptor/DeploymentStructureDescriptorParser.java @@ -288,7 +288,7 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D // additional modules will not be created till much later, a dep on them would fail if (identifier.getName().startsWith(ServiceModuleLoader.MODULE_PREFIX) && !(additionalModules.containsKey(identifier) || isSubdeployment(identifier, deploymentUnit))) { - phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleServiceName(identifier)); + phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleServiceName(identifier.getName())); } } moduleSpec.setLocalLast(rootDeploymentSpecification.isLocalLast()); diff --git a/server/src/main/java/org/jboss/as/server/logging/ServerLogger.java b/server/src/main/java/org/jboss/as/server/logging/ServerLogger.java index 36c63a3b74b..bd6b3b37946 100644 --- a/server/src/main/java/org/jboss/as/server/logging/ServerLogger.java +++ b/server/src/main/java/org/jboss/as/server/logging/ServerLogger.java @@ -731,7 +731,7 @@ public interface ServerLogger extends BasicLogger { IllegalStateException serviceModuleLoaderAlreadyStopped(); @Message(id = 99, value = "'%s' cannot be loaded from a ServiceModuleLoader as its name does not start with '%s'") - IllegalArgumentException missingModulePrefix(ModuleIdentifier identifier, String prefix); + IllegalArgumentException missingModulePrefix(String name, String prefix); @Message(id = 100, value = "Failed to read '%s'") DeploymentUnitProcessingException failedToReadVirtualFile(VirtualFile file, @Cause IOException cause); diff --git a/server/src/main/java/org/jboss/as/server/moduleservice/ExtensionIndexService.java b/server/src/main/java/org/jboss/as/server/moduleservice/ExtensionIndexService.java index 8b06a10a29a..08258cbcf6f 100644 --- a/server/src/main/java/org/jboss/as/server/moduleservice/ExtensionIndexService.java +++ b/server/src/main/java/org/jboss/as/server/moduleservice/ExtensionIndexService.java @@ -95,7 +95,7 @@ public boolean accept(final File file) { // now register a module spec service for this extension // this makes it available for loading ExternalModuleSpecService service = new ExternalModuleSpecService(moduleIdentifier, jar); - ServiceName serviceName = ServiceModuleLoader.moduleSpecServiceName(moduleIdentifier); + ServiceName serviceName = ServiceModuleLoader.moduleSpecServiceName(moduleIdentifier.getName()); ServiceBuilder sb = context.getChildTarget().addService(serviceName, service); sb.requires(org.jboss.as.server.deployment.Services.JBOSS_DEPLOYMENT_EXTENSION_INDEX); sb.setInitialMode(Mode.ON_DEMAND); diff --git a/server/src/main/java/org/jboss/as/server/moduleservice/ExternalModuleService.java b/server/src/main/java/org/jboss/as/server/moduleservice/ExternalModuleService.java index 23a3fd2c1ef..00dd36391e1 100644 --- a/server/src/main/java/org/jboss/as/server/moduleservice/ExternalModuleService.java +++ b/server/src/main/java/org/jboss/as/server/moduleservice/ExternalModuleService.java @@ -56,7 +56,7 @@ public ModuleIdentifier addExternalModule(String moduleName, ServiceRegistry ser @Override public ModuleIdentifier addExternalModule(String moduleName, String path, ServiceRegistry serviceRegistry, ServiceTarget serviceTarget) { ModuleIdentifier identifier = ModuleIdentifier.create(EXTERNAL_MODULE_PREFIX + moduleName); - ServiceName serviceName = ServiceModuleLoader.moduleSpecServiceName(identifier); + ServiceName serviceName = ServiceModuleLoader.moduleSpecServiceName(identifier.getName()); ServiceController controller = serviceRegistry.getService(serviceName); if (controller == null) { ExternalModuleSpecService service = new ExternalModuleSpecService(identifier, new File(path)); diff --git a/server/src/main/java/org/jboss/as/server/moduleservice/ExternalModuleSpecService.java b/server/src/main/java/org/jboss/as/server/moduleservice/ExternalModuleSpecService.java index 638ad17a01e..89fc44fad24 100644 --- a/server/src/main/java/org/jboss/as/server/moduleservice/ExternalModuleSpecService.java +++ b/server/src/main/java/org/jboss/as/server/moduleservice/ExternalModuleSpecService.java @@ -112,7 +112,7 @@ public synchronized void start(StartContext context) throws StartException { this.moduleDefinition = new ModuleDefinition(moduleIdentifier, Collections.emptySet(), moduleSpec); - ServiceModuleLoader.installModuleResolvedService(context.getChildTarget(), moduleIdentifier); + ServiceModuleLoader.installModuleResolvedService(context.getChildTarget(), moduleIdentifier.getName()); } @Override diff --git a/server/src/main/java/org/jboss/as/server/moduleservice/ModuleLoadService.java b/server/src/main/java/org/jboss/as/server/moduleservice/ModuleLoadService.java index 75ec2772b63..5c3b43cb31a 100644 --- a/server/src/main/java/org/jboss/as/server/moduleservice/ModuleLoadService.java +++ b/server/src/main/java/org/jboss/as/server/moduleservice/ModuleLoadService.java @@ -113,12 +113,12 @@ public Module getValue() throws IllegalStateException, IllegalArgumentException } private static ServiceName install(final ServiceTarget target, final ModuleIdentifier identifier, ModuleLoadService service) { - final ServiceName serviceName = ServiceModuleLoader.moduleServiceName(identifier); + final ServiceName serviceName = ServiceModuleLoader.moduleServiceName(identifier.getName()); final ServiceBuilder builder = target.addService(serviceName, service); builder.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ServiceModuleLoader.class, service.getServiceModuleLoader()); - builder.addDependency(ServiceModuleLoader.moduleSpecServiceName(identifier), ModuleDefinition.class, service.getModuleDefinitionInjectedValue()); - builder.requires(ServiceModuleLoader.moduleResolvedServiceName(identifier)); //don't attempt to load until all dependent module specs are up, even transitive ones + builder.addDependency(ServiceModuleLoader.moduleSpecServiceName(identifier.getName()), ModuleDefinition.class, service.getModuleDefinitionInjectedValue()); + builder.requires(ServiceModuleLoader.moduleResolvedServiceName(identifier.getName())); //don't attempt to load until all dependent module specs are up, even transitive ones builder.setInitialMode(Mode.ON_DEMAND); builder.install(); diff --git a/server/src/main/java/org/jboss/as/server/moduleservice/ModuleResolvePhaseService.java b/server/src/main/java/org/jboss/as/server/moduleservice/ModuleResolvePhaseService.java index cc40c63da90..307960d4446 100644 --- a/server/src/main/java/org/jboss/as/server/moduleservice/ModuleResolvePhaseService.java +++ b/server/src/main/java/org/jboss/as/server/moduleservice/ModuleResolvePhaseService.java @@ -65,7 +65,7 @@ public void start(final StartContext startContext) throws StartException { if (spec != null) { //this can happen for optional dependencies for (ModuleDependency dep : spec.getDependencies()) { if (dep.isOptional()) continue; // we don't care about optional dependencies - if (ServiceModuleLoader.isDynamicModule(dep.getIdentifier())) { + if (ServiceModuleLoader.isDynamicModule(dep.getIdentifier().getName())) { if (!alreadyResolvedModules.contains(dep.getIdentifier())) { nextAlreadySeen.add(dep.getIdentifier()); nextPhaseIdentifiers.add(dep); @@ -75,7 +75,7 @@ public void start(final StartContext startContext) throws StartException { } } if (nextPhaseIdentifiers.isEmpty()) { - ServiceModuleLoader.installModuleResolvedService(startContext.getChildTarget(), moduleIdentifier); + ServiceModuleLoader.installModuleResolvedService(startContext.getChildTarget(), moduleIdentifier.getName()); } else { installService(startContext.getChildTarget(), moduleIdentifier, phaseNumber + 1, nextPhaseIdentifiers, nextAlreadySeen); } @@ -92,7 +92,7 @@ private static void installService(final ServiceTarget serviceTarget, final Modu final ModuleResolvePhaseService nextPhaseService = new ModuleResolvePhaseService(moduleIdentifier, nextAlreadySeen, phaseNumber); ServiceBuilder builder = serviceTarget.addService(moduleSpecServiceName(moduleIdentifier, phaseNumber), nextPhaseService); for (ModuleDependency module : nextPhaseIdentifiers) { - builder.addDependency(ServiceModuleLoader.moduleSpecServiceName(module.getIdentifier()), ModuleDefinition.class, new Injector() { + builder.addDependency(ServiceModuleLoader.moduleSpecServiceName(module.getIdentifier().getName()), ModuleDefinition.class, new Injector() { ModuleDefinition definition; @@ -127,8 +127,8 @@ public Set getModuleSpecs() { } public static ServiceName moduleSpecServiceName(ModuleIdentifier identifier, int phase) { - if (!ServiceModuleLoader.isDynamicModule(identifier)) { - throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier, ServiceModuleLoader.MODULE_PREFIX); + if (!ServiceModuleLoader.isDynamicModule(identifier.getName())) { + throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier.getName(), ServiceModuleLoader.MODULE_PREFIX); } return SERVICE_NAME.append(identifier.getName()).append(identifier.getSlot()).append("" + phase); } diff --git a/server/src/main/java/org/jboss/as/server/moduleservice/ServiceModuleLoader.java b/server/src/main/java/org/jboss/as/server/moduleservice/ServiceModuleLoader.java index b5ba25ad026..18887c01726 100644 --- a/server/src/main/java/org/jboss/as/server/moduleservice/ServiceModuleLoader.java +++ b/server/src/main/java/org/jboss/as/server/moduleservice/ServiceModuleLoader.java @@ -11,7 +11,6 @@ import org.jboss.as.server.logging.ServerLogger; import org.jboss.as.server.Services; import org.jboss.modules.Module; -import org.jboss.modules.ModuleIdentifier; import org.jboss.modules.ModuleLoadException; import org.jboss.modules.ModuleLoader; import org.jboss.modules.ModuleSpec; @@ -130,10 +129,10 @@ protected Module preloadModule(final String name) throws ModuleLoadException { @SuppressWarnings("unchecked") @Override - public ModuleSpec findModule(ModuleIdentifier identifier) throws ModuleLoadException { - ServiceController controller = (ServiceController) serviceContainer.getService(moduleSpecServiceName(identifier)); + public ModuleSpec findModule(String name) throws ModuleLoadException { + ServiceController controller = (ServiceController) serviceContainer.getService(moduleSpecServiceName(name)); if (controller == null) { - ServerLogger.MODULE_SERVICE_LOGGER.debugf("Could not load module '%s' as corresponding module spec service '%s' was not found", identifier, identifier); + ServerLogger.MODULE_SERVICE_LOGGER.debugf("Could not load module '%s' as corresponding module spec service '%s' was not found", name, name); return null; } UninterruptibleCountDownLatch latch = new UninterruptibleCountDownLatch(1); @@ -191,22 +190,22 @@ public static void addService(final ServiceTarget serviceTarget, final Bootstrap /** * Returns the corresponding ModuleSpec service name for the given module. * - * @param identifier The module identifier + * @param name The module name * @return The service name of the ModuleSpec service */ - public static ServiceName moduleSpecServiceName(ModuleIdentifier identifier) { - if (!isDynamicModule(identifier)) { - throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier, MODULE_PREFIX); + public static ServiceName moduleSpecServiceName(String name) { + if (!isDynamicModule(name)) { + throw ServerLogger.ROOT_LOGGER.missingModulePrefix(name, MODULE_PREFIX); } - return MODULE_SPEC_SERVICE_PREFIX.append(identifier.getName()).append(identifier.getSlot()); + return MODULE_SPEC_SERVICE_PREFIX.append(name); } - public static void installModuleResolvedService(ServiceTarget serviceTarget, ModuleIdentifier identifier) { - final ServiceName sn = ServiceModuleLoader.moduleResolvedServiceName(identifier); + public static void installModuleResolvedService(ServiceTarget serviceTarget, String name) { + final ServiceName sn = ServiceModuleLoader.moduleResolvedServiceName(name); final ServiceBuilder sb = serviceTarget.addService(sn); - final Consumer moduleIdConsumer = sb.provides(sn); - sb.requires(moduleSpecServiceName(identifier)); - final org.jboss.msc.Service resolvedService = org.jboss.msc.Service.newInstance(moduleIdConsumer, identifier); + final Consumer moduleIdConsumer = sb.provides(sn); + sb.requires(moduleSpecServiceName(name)); + final org.jboss.msc.Service resolvedService = org.jboss.msc.Service.newInstance(moduleIdConsumer, name); sb.setInstance(resolvedService); sb.install(); } @@ -218,33 +217,33 @@ public static void installModuleResolvedService(ServiceTarget serviceTarget, Mod * until all the transitive dependencies that it depends upon have have their module spec services * come up. * - * @param identifier The module identifier + * @param name The module name * @return The service name of the ModuleSpec service */ - public static ServiceName moduleResolvedServiceName(ModuleIdentifier identifier) { - if (!isDynamicModule(identifier)) { - throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier, MODULE_PREFIX); + public static ServiceName moduleResolvedServiceName(String name) { + if (!isDynamicModule(name)) { + throw ServerLogger.ROOT_LOGGER.missingModulePrefix(name, MODULE_PREFIX); } - return MODULE_RESOLVED_SERVICE_PREFIX.append(identifier.getName()).append(identifier.getSlot()); + return MODULE_RESOLVED_SERVICE_PREFIX.append(name); } /** * Returns true if the module identifier is a dynamic module that will be loaded by this module loader */ - public static boolean isDynamicModule(ModuleIdentifier identifier) { - return identifier.getName().startsWith(MODULE_PREFIX); + public static boolean isDynamicModule(String name) { + return name.startsWith(MODULE_PREFIX); } /** * Returns the corresponding ModuleLoadService service name for the given module. * - * @param identifier The module identifier + * @param name The module name * @return The service name of the ModuleLoadService service */ - public static ServiceName moduleServiceName(ModuleIdentifier identifier) { - if (!identifier.getName().startsWith(MODULE_PREFIX)) { - throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier, MODULE_PREFIX); + public static ServiceName moduleServiceName(String name) { + if (!name.startsWith(MODULE_PREFIX)) { + throw ServerLogger.ROOT_LOGGER.missingModulePrefix(name, MODULE_PREFIX); } - return MODULE_SERVICE_PREFIX.append(identifier.getName()).append(identifier.getSlot()); + return MODULE_SERVICE_PREFIX.append(name); } }