Creating Module

Do you want to create a Guice module that will be loaded when your application starts? Nothing could be simpler than creating an implementation of the abstract class AbstractModule or the interface Module.

To meet all needs, the Void Framework provides the ability to obtain additional information via the module’s constructor. As a constructor’s parameter, you could optionally use the following elements:

  • Config the current configuration of the application
  • ScannedClassesToLoad the classes that were scanned when the application started

if a module needs to be loaded before another, you can use the OrderedModule interface.


Example

public final class MyCustomModule extends AbstractModule implements OrderedModule {

    private final Config configuration;
    private final ScannedClassesToLoad scannedClassesToLoad;

    public MyCustomModule(final Config configuration,
                          final ScannedClassesToLoad scannedClassesToLoad) {

        this.configuration = configuration;
        this.scannedClassesToLoad = scannedClassesToLoad;
    }

    @Override
    protected void configure() {
    
        // Place your module code here
    }

    @Override
    public int priority() {

        return 50;
    }
}