Skip to content

Java library for loading, reloading and unloading modules in runtime.

Notifications You must be signed in to change notification settings

asyncdargen/modulo

Repository files navigation

Modulo

Java library for simplest loading, reloading and unloading modules in runtime.


Environment

Any JRE is supported. But for the redefinition module classes, instead of a total reload, it requires the use of JBR with the JVM argument -XX:+AllowEnhancedClassRedefinition.


Add to project

Connect to jitpack.io repository

repositories {
    maven { url 'https://jitpack.io' }
}

Add dependency com.github.asyncdargen:modulo:VERSION

dependencies {
    implementation 'com.github.asyncdargen:modulo:VERSION'
}

Module loading

//Use `Module ClassLoaderFactory.depend()` if the modules will depend on each other
Modulo modulo = Modulo.create(ModuleClassLoaderFactory.isolated()); 

//Loading
modulo.loadModule(ModuleLoader.loadInfo(Paths.get("module.jar")));

//Reload
modulo.reloadModule(ModuleLoader.loadInfo(Paths.get("module.jar")));

//Unload
modulo.unloadModule("example");

Module example

class ExampleModule implements ModuleEntrypoint {

    @Override
    public void enable() {
        System.out.println("[Test] Enabled");
    }

    @Override
    public void reload() {
        System.out.println("[Test] Reloaded");
    }

    @Override
    public void disable() {
        System.out.println("[Test] Disabled");
    }

}

module.properties:

name=example
entrypoint=path.to.ExampleModule

#Using kotlin object as ModuleEntrypoint
kotlin-object-entrypoint=false

For depend classloader strategy

#By default all modules accessed to all modules
isolate=false
#Allow access in all modules
force-depend=false

#Allow access if isolated module ([, ]), example: depends=test, test2,example-depend
#depends=example-depend 

BuiltIn Loaders

Directory watch loader

Modulo modulo = //...;
ModuleFilesLoader.watch(module, "modules/");

About

Java library for loading, reloading and unloading modules in runtime.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages