in core/bootstrap/src/main/java/org/wildfly/swarm/bootstrap/modules/BootstrapClasspathModuleFinder.java [46:102]
public ModuleSpec findModule(String identifier, ModuleLoader delegateLoader) throws ModuleLoadException {
String simpleIdentifier = identifier;
if (!identifier.contains(":")) {
identifier = identifier + ":main";
}
try (AutoCloseable handle = Performance.accumulate("module: BootstrapClassPath")) {
final String[] nameAndSlot = identifier.split("\\:", 2);
final String path = "modules/" + nameAndSlot[0].replace('.', MODULE_SEPARATOR) + MODULE_SEPARATOR + nameAndSlot[1] + "/module.xml";
ClassLoader cl = BootstrapClasspathModuleFinder.class.getClassLoader();
URL url = cl.getResource(path);
if (url == null) {
return null;
}
ModuleSpec moduleSpec = null;
InputStream in = null;
try {
final URL base = new URL(url, "./");
in = url.openStream();
moduleSpec = ModuleXmlParser.parseModuleXml(
(rootPath, loaderPath, loaderName) -> {
if ("".equals(rootPath)) { // Maven artifact TODO is there a better way to recognize this?
return ResourceLoaders.createJarResourceLoader(loaderName,
JarFileManager.INSTANCE.getJarFile(new File(loaderPath)));
} else { // resource root
return NestedJarResourceLoader.loaderFor(base, rootPath, loaderPath, loaderName);
}
},
MavenResolvers.get(),
"/",
in,
path,
delegateLoader,
simpleIdentifier);
} catch (IOException e) {
throw new ModuleLoadException(e);
} catch (Throwable t) {
throw t;
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
throw new ModuleLoadException(e);
}
}
return moduleSpec;
} catch (Exception e) {
throw new RuntimeException(e);
}
}