Skip to content
Pierre T. edited this page Jan 12, 2015 · 7 revisions

Plugin is the main API used by Nuun users. Its role is to provide scan request to the kernel and compute the results to provide classes to bind to the DI engine (e.g. Guice Module).

Different types of plugin

Plugins can have different kind of concern:

  • Boostraping the application (WebPlugin, CLIPlugin, ITPlugin)
  • Implementing technical support for a third-party library (JMS, Apache Shiro, etc.)
  • Implementing business convention (Domain Driven Design)

Create a Plugin

  • Extend AbstractPlugin. This abstract class provides default method for the Plugin interface, so when you extend it, the only mandatory method is public String name().
public class MyPlugin extends AbstractPlugin {

    @Override
    public String name() {
        return "my-plugin";
    }

    ...
}
  • Register the plugin using the service loader. Add a file io.nuun.kernel.api.Plugin in the META-INF/services directory referring your plugin.

Now that you have your plugin,

  • Do some action at the plugin life cycle steps (See Plugin life cycle).
  • Do some requests to the kernel by implementing associated methods (See Request API).
  • If you have some classes to bind implements the following method (See Native module).
@Override
public Object nativeUnitModule() {
    return new MyModule(classesToBind); // Could be a Guice Module
}

Notice that these steps are optional, is it regarding your needs.

Content

Clone this wiki locally