Class PluginsService

java.lang.Object
org.elasticsearch.plugins.PluginsService
All Implemented Interfaces:
ReportingService<PluginsAndModules>

public class PluginsService extends Object implements ReportingService<PluginsAndModules>
  • Field Details

  • Constructor Details

    • PluginsService

      public PluginsService(Settings settings, Path configPath, Path modulesDirectory, Path pluginsDirectory)
      Constructs a new PluginService
      Parameters:
      settings - The settings of the system
      modulesDirectory - The directory modules exist in, or null if modules should not be loaded from the filesystem
      pluginsDirectory - The directory plugins exist in, or null if plugins should not be loaded from the filesystem
  • Method Details

    • getStablePluginRegistry

      public StablePluginsRegistry getStablePluginRegistry()
    • map

      public final <T> Stream<T> map(Function<Plugin,T> function)
      Map a function over all plugins
      Type Parameters:
      T - The generic type of the result
      Parameters:
      function - a function that takes a plugin and returns a result
      Returns:
      A stream of results
    • flatMap

      public final <T> Stream<T> flatMap(Function<Plugin,Collection<T>> function)
      FlatMap a function over all plugins
      Type Parameters:
      T - The generic type of the collection
      Parameters:
      function - a function that takes a plugin and returns a collection
      Returns:
      A stream of results
    • forEach

      public final void forEach(Consumer<Plugin> consumer)
      Apply a consumer action to each plugin
      Parameters:
      consumer - An action that consumes a plugin
    • pluginMap

      public final Map<String,Plugin> pluginMap()
      Sometimes we want the plugin name for error handling.
      Returns:
      A map of plugin names to plugin instances.
    • info

      public PluginsAndModules info()
      Get information about plugins and modules
      Specified by:
      info in interface ReportingService<PluginsAndModules>
    • plugins

      protected List<org.elasticsearch.plugins.PluginsService.LoadedPlugin> plugins()
    • loadServiceProviders

      public <T> List<? extends T> loadServiceProviders(Class<T> service)
      SPI convenience method that uses the ServiceLoader JDK class to load various SPI providers from plugins/modules.

      For example:

       var pluginHandlers = pluginsService.loadServiceProviders(OperatorHandlerProvider.class);
       
      Parameters:
      service - A templated service class to look for providers in plugins
      Returns:
      an immutable List of discovered providers in the plugins/modules
    • filterPlugins

      public final <T> List<T> filterPlugins(Class<T> type)
    • getPluginsServiceCtor

      public static Function<Settings,PluginsService> getPluginsServiceCtor(Environment environment)
      Get a function that will take a Settings object and return a PluginsService. This function passes in an empty list of classpath plugins.
      Parameters:
      environment - The environment for the plugins service.
      Returns:
      A function for creating a plugins service.