Interface ServiceManager
- All Known Implementing Classes:
ServiceManager.SimpleServiceManager
public interface ServiceManager
Adds and accesses BesuServices for plugins to provide or use.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA basic implementation of ServiceManager, suitable for tests. -
Method Summary
Modifier and TypeMethodDescription<T extends BesuService>
voidaddService(Class<T> serviceType, T service) Add service.<T extends BesuService>
Optional<T> getService(Class<T> serviceType) Get the requested service, if it is available.
-
Method Details
-
addService
Add service. Used by core besu or other plugins to add services to the service manager.- Type Parameters:
T- the type parameter- Parameters:
serviceType- the service typeservice- the service
-
getService
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.
- 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
- The service may not have started yet. Most services are not available before the
-