Class ServiceManager.SimpleServiceManager

java.lang.Object
org.hyperledger.besu.plugin.ServiceManager.SimpleServiceManager
All Implemented Interfaces:
ServiceManager
Enclosing interface:
ServiceManager

public static class ServiceManager.SimpleServiceManager extends Object implements ServiceManager
A basic implementation of ServiceManager, suitable for tests.
  • Constructor Details

    • SimpleServiceManager

      public SimpleServiceManager()
      default constructor. commented here to appease the linter.
  • Method Details

    • addService

      public <T extends BesuService> void addService(Class<T> serviceType, T service)
      Description copied from interface: ServiceManager
      Add service. Used by core besu or other plugins to add services to the service manager.
      Specified by:
      addService in interface ServiceManager
      Type Parameters:
      T - the type parameter
      Parameters:
      serviceType - the service type
      service - the service
    • getService

      public <T extends BesuService> Optional<T> getService(Class<T> serviceType)
      Description copied from interface: ServiceManager
      Get the requested service, if it is available. There are a number of reasons that a service may not be available:
      • The service may not have started yet. Most services are not available before the BesuPlugin.start() method is called
      • The service is not supported by this version of Besu
      • The service may not be applicable to the current configuration. For example some services may only be available when a proof of authority network is in use, or when user provided.

      Since plugins are automatically loaded, unless the user has specifically requested functionality provided by the plugin, no error should be raised if required services are unavailable.

      Specified by:
      getService in interface ServiceManager
      Type Parameters:
      T - the service type
      Parameters:
      serviceType - the class defining the requested service.
      Returns:
      an optional containing the instance of the requested service, or empty if the service is unavailable