ModularKit, an alternative to the OSGi framework, more lightweight and powerful Java toolkit for creating modular apps.
With ModularKit, you can create modular apps with increased flexibility and stability, designed to create projects without server shutdown and a good maintainability.
Checkout the documentation on the documentation folder: * docs.*
First, you need to create a new project (maven recommended) and add ModularKit dependency :
<dependency>
<groupId>works.nuka</groupId>
<artifactId>ModularKit</artifactId>
<version>{ Check maven-central badge }</version>
</dependency>
<dependency>
<groupId>works.nuka</groupId>
<artifactId>ModularKit</artifactId>
<version>{ Check maven-central badge }</version>
<scope>provided</scope>
</dependency>
Use this ModuleTemplate : https://github.com/NukaWorks/ModuleTest
First example : HelloWorld !
package com.example;
import works.nuka.modularkit.ModularModule;
public class ModuleTest extends ModularModule {
public ModuleTest() throws Exception {
super("ModuleTest", "81f9ab59", "Sundev79", "1.0.0");
}
@Override
public void runEvent() {
System.out.println("Hello World !");
}
}
An example with module-dependencies : you can add others dependant module by this way :
package com.example;
import works.nuka.modularkit.ModularModule;
public class ModuleTest extends ModularModule {
public ModuleTest() {
AnotherModule anotherMod = new AnotherModule();
AnotherModule anotherMod2 = new AnotherModule();
super("ModuleTest", "81f9ab59", "Sundev79", "1.0.0", anotherMod, anotherMod2);
// You can use Module dependencies !
}
@Override
public void runEvent() {
System.out.println("Hello World with module-dependencies !");
}
}
For running a module, let's try this little example :
import works.nuka.modularkit.ModularSource;
import ModuleTest;
public class Main {
public static void main() {
// Register the source first
ModularSource mainSource = new ModularSource("e3640e55");
// and the Module ...
ModuleTest testMod = new ModuleTest();
// ... and then let's run it !
mainSource.getModuleManager().runModule(testMod);
}
}
For ModSource and Module you need to generate a new uuid (Group 1).
~$ uuidgen
**e3640e55**-cbaf-42c2-b053-52a2cfa2e0a5
~$
You can use https://www.uuidgenerator.net/
⚠ You need to copy the group 1 of the uuid.
docs*