Skip to content
Pierre T. edited this page Apr 30, 2015 · 2 revisions

Kernel extensions provide an SPI to enhanced the kernel behavior.

Create a kernel extension

  1. Create a class implementing the KernelExtension interface

  2. Create a marker interface associated to the extension as follows:

  3. Register the extension using the service loader. Add a file io.nuun.kernel.spi.KernelExtension under META-INF/services.

public class MyFeatureExtension implements KernelExtension<MyFeature> {

    @Override
    public void initializing(Collection<MyExtensionInterface> extensions) {
        ...
    }

    @Override
    public void initialized(Collection<MyExtensionInterface> extensions) {
        ...
    }

    @Override
    public void starting(Collection<MyExtensionInterface> extensions) {
        ..
    }

    @Override
    public void started(Collection<MyExtensionInterface> extensions) {
        ...
    }

    @Override
    public void stopping(Collection<MyExtensionInterface> extensions) {
        ...
    }

    @Override
    public void stopped(Collection<MyExtensionInterface> extensions) {
        ...
    }
}
public interface MyFeature {
    ...
}

Use a kernel extension

Create a plugin implementing the extension marker.

public class MyPlugin extends AbstractPlugin implements MyFeature {
    ...
}

Extension lifecycle

The kernel extension will be called at each step of the kernel lifecycle (initializing, initialized, starting, etc.). The list of plugins implementing the kernel extension marker will be passed to the kernel extension at each method call.

Extension sample

See the kernel-listener extension.

Content

Clone this wiki locally