Package org.hyperledger.besu.plugin
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 theServiceLoader
documentation for how to register plugins.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Optional<java.lang.String>
getName()
Returns the name of the plugin.void
register(BesuContext context)
Called when the plugin is first registered with Besu.default java.util.concurrent.CompletableFuture<java.lang.Void>
reloadConfiguration()
Called when the plugin is being reloaded.void
start()
Called once Besu has loaded configuration and is starting up.void
stop()
Called when the plugin is being stopped.
-
-
-
Method Detail
-
getName
default java.util.Optional<java.lang.String> getName()
Returns the name of the plugin. This name is used to trigger specific actions on individual plugins.- Returns:
- an
Optional
wrapping the unique name of the plugin.
-
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.
-
reloadConfiguration
default java.util.concurrent.CompletableFuture<java.lang.Void> reloadConfiguration()
Called when the plugin is being reloaded. This method will be called trough 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.
-
-