Skip to content

ModularKit, an alternative to the OSGi framework, more lightweight and powerful Java toolkit for creating modular apps.

License

Notifications You must be signed in to change notification settings

NukaWorks/ModularKit

Codacy Badge Nightly Builder CodeQL Maven Central Lines of code GitHub code size in bytes GitHub Licence

ModularKit

What is ModularKit ?

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.*

Getting started

First, you need to create a new project (maven recommended) and add ModularKit dependency :

For creating a modular-based app (Client side) :

<dependency>
    <groupId>works.nuka</groupId>
    <artifactId>ModularKit</artifactId>
    <version>{ Check maven-central badge }</version>
</dependency>

For external module (Module side) :

Create manualy

<dependency>
    <groupId>works.nuka</groupId>
    <artifactId>ModularKit</artifactId>
    <version>{ Check maven-central badge }</version>
    <scope>provided</scope>
</dependency>

Or use the ModuleTemplate

Use this ModuleTemplate : https://github.com/NukaWorks/ModuleTest

Examples

How to create a Modular hello-world

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 registering and run a module

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).

MacOS/Linux and others unix systems

~$ uuidgen
**e3640e55**-cbaf-42c2-b053-52a2cfa2e0a5
~$

UUIDGEN Online

You can use https://www.uuidgenerator.net/

You need to copy the group 1 of the uuid.

You can find the full documentation on the directory : *

docs*

Social links

See on Powerm1nt Profile