Interface BesuPlugin


  • public interface BesuPlugin
    Base interface for Besu plugins.

    Plugins are discovered and loaded using ServiceLoader from jar files within Besu's plugin directory. See the ServiceLoader documentation for how to register plugins.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void register​(BesuContext context)
      Called when the plugin is first registered with Besu.
      void start()
      Called once Besu has loaded configuration and is starting up.
      void stop()
      Called when the plugin is being stopped.
    • Method Detail

      • register

        void register​(BesuContext context)
        Called when the plugin is first registered with Besu. Plugins are registered very early in the Besu life-cycle and should use this callback to register any command line options required via the PicoCLIOptions service.

        The context parameter should be stored in a field in the plugin. This is the only time it will be provided to the plugin and is how the plugin will interact with Besu.

        Typically the plugin will not begin operation until the start() method is called.

        Parameters:
        context - the context that provides access to Besu services.
      • start

        void start()
        Called once Besu has loaded configuration and is starting up. The plugin should begin operation, including registering any event listener with Besu services and starting any background threads the plugin requires.
      • stop

        void stop()
        Called when the plugin is being stopped. This method will be called as part of Besu shutting down but may also be called at other times to disable the plugin.

        The plugin should remove any registered listeners and stop any background threads it started.