class JBossModulesPlugin {

    protected static AgentLogger LOGGER = AgentLogger.getLogger(JBossModulesPlugin.class);

    // TODO : Skip system packages, it should be in config file
    private static final String SKIP_MODULES_REGEXP = "sun\\.jdk.*|ibm\\.jdk.*|javax\\..*|org\\.jboss\\..*";
    private static final String USE_MODULES_REGEXP = "deployment\\..*";

    @Init
    ClassLoader moduleClassLoader;

    @Init
    public void init(PluginConfiguration pluginConfiguration) {
        LOGGER.info("JBossModules plugin plugin initialized.");
    }

    @OnClassLoadEvent(classNameRegexp = "org.jboss.modules.ModuleLoader")
    public static void transformModule(ClassPool classPool, CtClass ctClass) throws NotFoundException, CannotCompileException {<FILL_FUNCTION_BODY>}
}

        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("$2.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()") +
                        "}"
                    );

        }

        LOGGER.debug("Class 'org.jboss.modules.Module' patched.");
    
<no_super_class>