Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-7170] Reduce ModuleIdentifier usage from Server module #6350

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions server/src/main/java/org/jboss/as/server/BootstrapImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
import javax.management.ObjectName;

import org.jboss.as.controller.ControlledProcessState;
import org.jboss.as.controller.ProcessStateNotifier;
import org.jboss.as.controller.ControlledProcessStateService;
import org.jboss.as.controller.ProcessStateNotifier;
import org.jboss.as.server.jmx.RunningStateJmx;
import org.jboss.as.server.logging.ServerLogger;
import org.jboss.as.server.suspend.SuspendController;
import org.jboss.as.server.suspend.ServerSuspendController;
import org.jboss.as.server.suspend.SuspendController;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.modules.ModuleLoader;
import org.jboss.msc.service.LifecycleEvent;
Expand Down Expand Up @@ -89,7 +88,7 @@ private AsyncFuture<ServiceContainer> internalBootstrap(final Configuration conf
assert configurationPersisterFactory != null : "configurationPersisterFactory is null";

try {
Module.registerURLStreamHandlerFactoryModule(moduleLoader.loadModule(ModuleIdentifier.create("org.jboss.vfs")));
Module.registerURLStreamHandlerFactoryModule(moduleLoader.loadModule("org.jboss.vfs"));
} catch (ModuleLoadException e) {
throw ServerLogger.ROOT_LOGGER.vfsNotAvailable();
}
Expand Down Expand Up @@ -299,7 +298,7 @@ private void suspend(ServiceContainer sc) {

private static long getSuspendTimeout() {
String timeoutString = System.getProperty(SIGTERM_SUSPEND_TIMEOUT_PROP);
if (timeoutString != null && timeoutString.length() > 0) {
if (timeoutString != null && !timeoutString.isEmpty()) {
try {
return Integer.decode(timeoutString);
} catch (NumberFormatException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.jboss.marshalling.SimpleClassResolver;
import org.jboss.marshalling.Unmarshaller;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.msc.service.ServiceActivator;
import org.jboss.msc.service.ServiceActivatorContext;
import org.jboss.msc.service.ServiceContainer;
Expand Down Expand Up @@ -118,7 +117,7 @@ public static void main(String[] args) {
final ByteInput byteInput;
final AsyncFuture<ServiceContainer> containerFuture;
try {
Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.vfs")));
Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule("org.jboss.vfs"));
final MarshallingConfiguration configuration = new MarshallingConfiguration();
configuration.setVersion(2);
configuration.setClassResolver(new SimpleClassResolver(DomainServerMain.class.getClassLoader()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.client.helpers.JBossModulesNameUtil;
import org.jboss.as.server.logging.ServerLogger;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoader;
import org.jboss.modules.management.DependencyInfo;
import org.jboss.modules.management.ModuleInfo;
Expand Down Expand Up @@ -103,14 +103,14 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
populateModel(operation, model);
String moduleName = MODULE_NAME.resolveModelAttribute(context, model).asString();
String slot = MODULE_SLOT.resolveModelAttribute(context, model).asString();
ModuleIdentifier id = ModuleIdentifier.create(moduleName, slot);
String id = JBossModulesNameUtil.canonicalModuleIdentifier(moduleName, slot);
ModuleLoader loader = Module.getBootModuleLoader();
try {
ModuleLoaderMXBean mxBean = getMxBean(loader);
ModuleInfo moduleInfo = mxBean.getModuleDescription(id.toString());
ModuleInfo moduleInfo = mxBean.getModuleDescription(id);
context.getResult().set(populateModuleInfo(moduleInfo));
} catch (Exception e) {
throw ServerLogger.ROOT_LOGGER.couldNotGetModuleInfo(id.toString(), e);
throw ServerLogger.ROOT_LOGGER.couldNotGetModuleInfo(id, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.client.helpers.JBossModulesNameUtil;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.server.controller.descriptions.ServerDescriptions;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.modules.LocalModuleFinder;
import org.jboss.modules.LocalModuleLoader;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.modules.ModuleLoader;
import org.jboss.modules.ModuleNotFoundException;
Expand Down Expand Up @@ -207,7 +207,7 @@ public List<String> run() throws Exception {
private static List<String> findResourcePaths(String moduleName) throws ModuleLoadException, ReflectiveOperationException, IOException, URISyntaxException {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleLoaderMXBean loader = ModuleInfoHandler.INSTANCE.getMxBean(moduleLoader);
moduleLoader.loadModule(ModuleIdentifier.fromString(moduleName));
moduleLoader.loadModule(JBossModulesNameUtil.parseCanonicalModuleIdentifier(moduleName));

List<String> result = new LinkedList<>();
for (ResourceLoaderInfo rl : loader.getResourceLoaders(moduleName)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.LIST_MODULES;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBDEPLOYMENT;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.VERBOSE;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.ENABLED;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.RUNTIME_NAME;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.VERBOSE;

import java.util.Collections;
import java.util.Comparator;
Expand All @@ -24,7 +24,6 @@
import org.jboss.as.server.moduleservice.ModuleLoadService;
import org.jboss.as.server.moduleservice.ServiceModuleLoader;
import org.jboss.dmr.ModelNode;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceRegistry;

Expand Down Expand Up @@ -59,19 +58,19 @@ public void execute(OperationContext context, ModelNode operation) {
final ServiceController<?> deploymentUnitSc = sr.getService(Services.deploymentUnitName(runtimeName));
final DeploymentUnit deploymentUnit = (DeploymentUnit) deploymentUnitSc.getValue();

ModuleIdentifier moduleIdentifier = null;
String moduleIdentifier = null;
if (subDeploymentFlag) {
for (DeploymentUnit subDeployment : deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)) {
if (subDeployment.getName().equals(item)) {
moduleIdentifier = subDeployment.getAttachment(Attachments.MODULE_IDENTIFIER);
moduleIdentifier = subDeployment.getAttachment(Attachments.MODULE_NAME);
break;
}
}
if (moduleIdentifier == null) {
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(currentAddress);
}
} else {
moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_NAME);
}

final ServiceController<?> moduleLoadServiceController = sr.getService(ServiceModuleLoader.moduleServiceName(moduleIdentifier.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.modules.ModuleIdentifier;

/**
* Processor that aggregates all module descriptions visible to the deployment in an EEApplicationClasses structure.
Expand Down Expand Up @@ -43,25 +42,25 @@ private void buildModuleMap(final DeploymentUnit deploymentUnit, final Map<Strin
if (deploymentUnit.getParent() == null) {
final List<DeploymentUnit> subDeployments = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.SUB_DEPLOYMENTS);
for (final DeploymentUnit sub : subDeployments) {
final ModuleIdentifier identifier = sub.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE_IDENTIFIER);
final String identifier = sub.getAttachment(Attachments.MODULE_NAME);
if (identifier != null) {
modules.put(identifier.toString(), sub);
modules.put(identifier, sub);
}
}
} else {
final DeploymentUnit parent = deploymentUnit.getParent();
final List<DeploymentUnit> subDeployments = parent.getAttachmentList(org.jboss.as.server.deployment.Attachments.SUB_DEPLOYMENTS);
//add the parent description
final ModuleIdentifier parentIdentifier = parent.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE_IDENTIFIER);
final String parentIdentifier = parent.getAttachment(Attachments.MODULE_NAME);
if (parentIdentifier != null) {
modules.put(parentIdentifier.toString(), parent);
modules.put(parentIdentifier, parent);
}

for (final DeploymentUnit sub : subDeployments) {
if (sub != deploymentUnit) {
final ModuleIdentifier identifier = sub.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE_IDENTIFIER);
final String identifier = sub.getAttachment(Attachments.MODULE_NAME);
if (identifier != null) {
modules.put(identifier.toString(), sub);
modules.put(identifier, sub);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.logging.annotations.Param;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.msc.service.ServiceController.State;
import org.jboss.msc.service.ServiceName;
Expand Down Expand Up @@ -997,7 +996,7 @@ public interface ServerLogger extends BasicLogger {
IllegalStateException externalModuleServiceAlreadyStarted();

@Message(id = 179, value = "Failed to load module: %s")
StartException failedToLoadModule(ModuleIdentifier module, @Cause ModuleLoadException cause);
StartException failedToLoadModule(String moduleName, @Cause ModuleLoadException cause);

//@Message(id = 180, value = "Timeout waiting for module service: %s")
//ModuleLoadException timeoutWaitingForModuleService(ModuleIdentifier module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public synchronized void start(StartContext context) throws StartException {
String val = moduleLoader.loadModule(id).getProperty("jboss.api");
if (val != null) {
if (val.equals("private")) {
ServerLogger.PRIVATE_DEP_LOGGER.privateApiUsed(moduleDefinitionInjectedValue.getValue().getModuleIdentifier().getName(), id);
ServerLogger.PRIVATE_DEP_LOGGER.privateApiUsed(moduleDefinitionInjectedValue.getValue().getModuleName(), id);
} else if (val.equals("unsupported")) {
ServerLogger.UNSUPPORTED_DEP_LOGGER.unsupportedApiUsed(moduleDefinitionInjectedValue.getValue().getModuleIdentifier().getName(), id);
ServerLogger.UNSUPPORTED_DEP_LOGGER.unsupportedApiUsed(moduleDefinitionInjectedValue.getValue().getModuleName(), id);
} else if (val.equals("deprecated")) {
ServerLogger.DEPRECATED_DEP_LOGGER.deprecatedApiUsed(moduleDefinitionInjectedValue.getValue().getModuleIdentifier().getName(), id);
ServerLogger.DEPRECATED_DEP_LOGGER.deprecatedApiUsed(moduleDefinitionInjectedValue.getValue().getModuleName(), id);
}
}
} catch (ModuleNotFoundException ignore) {
Expand All @@ -97,7 +97,7 @@ public synchronized void start(StartContext context) throws StartException {
}
this.module = module;
} catch (ModuleLoadException e) {
throw ServerLogger.ROOT_LOGGER.failedToLoadModule(moduleDefinitionInjectedValue.getValue().getModuleIdentifier(), e);
throw ServerLogger.ROOT_LOGGER.failedToLoadModule(moduleDefinitionInjectedValue.getValue().getModuleName(), e);
}
}

Expand Down
Loading