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-7133] Remove ModuleIdentifier use in domain-http-interface #6321

Merged
merged 1 commit into from
Jan 17, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import io.undertow.server.handlers.PredicateHandler;
import io.undertow.server.handlers.RedirectHandler;
import io.undertow.server.handlers.resource.ClassPathResourceManager;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.domain.http.server.logging.HttpServerLogger;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.modules.ModuleLoader;
import org.wildfly.security.manager.WildFlySecurityManager;
Expand Down Expand Up @@ -256,8 +256,7 @@ private static File[] getFiles(final String modulePath, final int stringIdx, fin


protected static ClassLoader getClassLoader(final ModuleLoader moduleLoader, final String module, final String slot) throws ModuleLoadException {
ModuleIdentifier id = ModuleIdentifier.create(module, slot);

String id = ModuleIdentifierUtil.canonicalModuleIdentifier(module, slot);
return moduleLoader.loadModule(id).getClassLoader();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import io.undertow.server.handlers.PredicateHandler;
import io.undertow.server.handlers.RedirectHandler;
import io.undertow.server.handlers.resource.ClassPathResourceManager;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.modules.ModuleLoader;

Expand Down Expand Up @@ -59,8 +59,7 @@ public static HttpHandler createErrorContext(final String slot) throws ModuleLoa
}

private static ClassLoader getClassLoader(final ModuleLoader moduleLoader, final String module, final String slot) throws ModuleLoadException {
ModuleIdentifier id = ModuleIdentifier.create(module, slot);

String id = ModuleIdentifierUtil.canonicalModuleIdentifier(module, slot);
return moduleLoader.loadModule(id).getClassLoader();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import java.io.File;

import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.modules.LocalModuleLoader;
import org.jboss.modules.ModuleClassLoader;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoader;
import org.junit.Test;

Expand All @@ -26,77 +26,77 @@ public class ConsoleModeTestCase {

@Test
public void testDefaultModules() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console"), "modules-default");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console"), "modules-default");
}


@Test
public void testVersionedNoSlot() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "1.2.1"), "modules-versioned");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "1.2.1"), "modules-versioned");
}

@Test
public void testVersionedAndMainSlot() throws Exception {
checkModule("main", ModuleIdentifier.create("org.jboss.as.console.main", "1.2.1"), "modules-versioned");
checkModule("main", ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "1.2.1"), "modules-versioned");
}

@Test
public void testVersionedLayersNoSlot() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "1.2.1"), "modules-base-and-layer1");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "1.2.1"), "modules-base-and-layer1");
}

@Test
public void testVersionedLayersAndMainSlot() throws Exception {
checkModule("main", ModuleIdentifier.create("org.jboss.as.console.main", "1.2.1"), "modules-base-and-layer1");
checkModule("main", ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "1.2.1"), "modules-base-and-layer1");
}

@Test
public void testSeveralRootsVersionedLayersNoSlot() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2");
}

@Test
public void testSeveralRootsVersionedLayersAndMainSlot() throws Exception {
checkModule("main", ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2");
checkModule("main", ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2");
}

@Test
public void testSeveralRootsDifferentOrderVersionedLayersNoSlot() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-layer2", "modules-base-and-layer1");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "3.0.0"), "modules-layer2", "modules-base-and-layer1");
}

@Test
public void testSeveralRootsDifferentOrderVersionedLayersAndMainSlot() throws Exception {
checkModule("main", ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-layer2", "modules-base-and-layer1");
checkModule("main", ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "3.0.0"), "modules-layer2", "modules-base-and-layer1");
}

@Test
public void testAddonsAndLayersAddon1WinsNoSlot() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "2.0.0"), "modules-base-and-layer1", "modules-addons1");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "2.0.0"), "modules-base-and-layer1", "modules-addons1");
}

@Test
public void testAddonsAndLayersLayer2WinsNoSlot() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2", "modules-addons1");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2", "modules-addons1");
}

@Test
public void testAddonsAndLayersAddon2WinsNoSlot() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "4.0.0"), "modules-base-and-layer1", "modules-layer2", "modules-addons1", "modules-addons2");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "4.0.0"), "modules-base-and-layer1", "modules-layer2", "modules-addons1", "modules-addons2");
}

@Test
public void testAddonsOnly() throws Exception {
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "4.0.0"), "modules-addons1", "modules-addons2");
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console.main", "4.0.0"), "modules-addons1", "modules-addons2");
}

private void checkModule(String slot, ModuleIdentifier expected, String...moduleDirNames) throws Exception {
private void checkModule(String slot, String expected, String...moduleDirNames) throws Exception {
ModuleLoader loader = createModuleLoader(moduleDirNames);
ClassLoader classLoader = ConsoleMode.ConsoleHandler.findConsoleClassLoader(loader, slot);
assertNotNull(classLoader);
assertTrue(classLoader instanceof ModuleClassLoader);
ModuleClassLoader moduleClassLoader = (ModuleClassLoader)classLoader;
assertEquals(expected, moduleClassLoader.getModule().getIdentifier());
assertEquals(expected, moduleClassLoader.getModule().getName());
}

private ModuleLoader createModuleLoader(String...moduleDirNames) {
Expand Down
Loading