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..e201677457f 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.toString())); 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..824ab7bff7a 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.toString())); } } 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..ea39967a3ce 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.toString())); } @@ -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.toString())); } 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 0fb3412c7cc..bfa770126f9 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.toString())); } } @@ -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.toString()); 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.fromString(aliasName); - final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias); + final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias.toString()); 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..b636c6558c0 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.toString())); } } 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 ff742703128..8d1394a897d 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 @@ -733,7 +733,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..effca26bd4f 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.toString()); 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..4e966b80727 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.toString()); 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..e7a2e143251 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.toString()); } @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..d42778c542a 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.toString()); 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.toString()), ModuleDefinition.class, service.getModuleDefinitionInjectedValue()); + builder.requires(ServiceModuleLoader.moduleResolvedServiceName(identifier.toString())); //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..4a5c72a771d 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().toString())) { 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.toString()); } 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().toString()), 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.toString())) { + throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier.toString(), 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..0634c2d132c 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 @@ -130,10 +130,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 +191,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,21 +218,21 @@ 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); } /** @@ -240,11 +240,23 @@ public static boolean isDynamicModule(ModuleIdentifier identifier) { * * @param identifier The module identifier * @return The service name of the ModuleLoadService service + * @deprecated Use {@link ServiceModuleLoader#moduleServiceName(String)} */ + @Deprecated(forRemoval = true) public static ServiceName moduleServiceName(ModuleIdentifier identifier) { - if (!identifier.getName().startsWith(MODULE_PREFIX)) { - throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier, MODULE_PREFIX); + return moduleServiceName(identifier.toString()); + } + + /** + * Returns the corresponding ModuleLoadService service name for the given module. + * + * @param name The module name + * @return The service name of the ModuleLoadService service + */ + 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); } }