Skip to content

Commit

Permalink
Support last jbossmoduless 1.10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
skybber committed Jun 19, 2020
1 parent 7bf4c58 commit 4550fa8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugin/hotswap-agent-jbossmodules-plugin/pom.xml
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>org.jboss.modules</groupId>
<artifactId>jboss-modules</artifactId>
<version>1.3.7.Final</version>
<version>1.10.1.Final</version>
</dependency>
</dependencies>
</project>
Expand Up @@ -36,7 +36,7 @@
*/
@Plugin(name = "JBossModules",
description = "JBossModules - Jboss modular class loading implementation. ",
testedVersions = {"1.4.4, 1.5.1"},
testedVersions = {"1.4.4, 1.5.1, 1.6.x, 1.7.x, 1.8.x, 1.9.x, 1.10.x"},
expectedVersions = {"1.x"},
supportClass={ModuleClassLoaderTransformer.class}
)
Expand All @@ -58,18 +58,32 @@ public void init(PluginConfiguration pluginConfiguration) {

@OnClassLoadEvent(classNameRegexp = "org.jboss.modules.ModuleLoader")
public static void transformModule(ClassPool classPool, CtClass ctClass) throws NotFoundException, CannotCompileException {
ctClass.getDeclaredMethod("loadModule", new CtClass[]{classPool.get("org.jboss.modules.ModuleIdentifier")}).insertAfter(
"if (identifier.getName().matches(\"" + USE_MODULES_REGEXP + "\")) {" +
try {
ctClass.getDeclaredMethod("loadModule", new CtClass[]{classPool.get(String.class.getName())}).insertAfter(
"if ($1.matches(\"" + USE_MODULES_REGEXP + "\")) {" +
PluginManagerInvoker.buildInitializePlugin(JBossModulesPlugin.class, "$_.getClassLoaderPrivate()") +
"}" +
"return $_;"
);
ctClass.getDeclaredMethod("unloadModuleLocal", new CtClass[]{classPool.get(String.class.getName()), classPool.get("org.jboss.modules.Module")}).insertBefore(
"if(!$1.matches(\"" + SKIP_MODULES_REGEXP + "\")) {" +
PluginManagerInvoker.buildCallCloseClassLoader("$1.getClassLoaderPrivate()") +
"}"
);
} catch (NotFoundException e) {
ctClass.getDeclaredMethod("loadModule", new CtClass[]{classPool.get("org.jboss.modules.ModuleIdentifier")}).insertAfter(
"if ($1.getName().matches(\"" + USE_MODULES_REGEXP + "\")) {" +
PluginManagerInvoker.buildInitializePlugin(JBossModulesPlugin.class, "$_.getClassLoaderPrivate()") +
"}" +
"return $_;"
);
ctClass.getDeclaredMethod("unloadModuleLocal", new CtClass[]{classPool.get("org.jboss.modules.Module")}).insertBefore(
"if(!$1.getIdentifier().getName().matches(\"" + SKIP_MODULES_REGEXP + "\")) {" +
PluginManagerInvoker.buildCallCloseClassLoader("$1.getClassLoaderPrivate()") +
"}"
);

ctClass.getDeclaredMethod("unloadModuleLocal", new CtClass[]{classPool.get("org.jboss.modules.Module")}).insertBefore(
"if(!$1.getIdentifier().getName().matches(\"" + SKIP_MODULES_REGEXP + "\")) {" +
PluginManagerInvoker.buildCallCloseClassLoader("$1.getClassLoaderPrivate()") +
"}"
);
}

LOGGER.debug("Class 'org.jboss.modules.Module' patched.");
}
Expand Down

0 comments on commit 4550fa8

Please sign in to comment.