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

    Modifier and Type
    Method
    Description
    default void
    Hook to execute plugin setup code after external services
    default void
    Called once when besu has loaded configuration but before external services have been started e.g.
    default String
    Returns the name of the plugin.
    default String
    Retrieves the version information of the plugin.
    void
    Called when the plugin is first registered with Besu.
    Called when the plugin is being reloaded.
    void
    Called once Besu has loaded configuration and has started external services but before the main loop is up.
    void
    Called when the plugin is being stopped.
  • Method Details

    • getName

      default String getName()
      Returns the name of the plugin. This name is used to trigger specific actions on individual plugins.
      Returns:
      the name of the plugin.
    • register

      void register(ServiceManager 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.
    • beforeExternalServices

      default void beforeExternalServices()
      Called once when besu has loaded configuration but before external services have been started e.g. metrics and http
    • start

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

      default void afterExternalServicePostMainLoop()
      Hook to execute plugin setup code after external services
    • reloadConfiguration

      default CompletableFuture<Void> reloadConfiguration()
      Called when the plugin is being reloaded. This method will be called through a dedicated JSON RPC endpoint. If not overridden this method does nothing for convenience. The plugin should only implement this method if it supports dynamic reloading.

      The plugin should reload its configuration dynamically or do nothing if not applicable.

      Returns:
      a CompletableFuture
    • 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.

    • getVersion

      default String getVersion()
      Retrieves the version information of the plugin. It constructs a version string using the implementation title and version from the package information. If either the title or version is not available, it defaults to "Unknown Implementation Title" and "Unknown Version", respectively.
      Returns:
      A string representing the plugin's version information, formatted as "Title/vVersion".