Class ExtensionLoader

java.lang.Object
org.elasticsearch.plugins.ExtensionLoader

public class ExtensionLoader extends Object
A utility for loading SPI extensions.
  • Constructor Details

    • ExtensionLoader

      public ExtensionLoader()
  • Method Details

    • loadSingleton

      public static <T> Optional<T> loadSingleton(ServiceLoader<T> loader)
      Loads a single SPI extension. There should be no more than one extension found. Note: A ServiceLoader is needed rather than the service class because ServiceLoaders must be loaded by a module with the uses declaration. Since this utility class is in server, it will not have uses (or even know about) all the service classes it may load. Thus, the caller must load the ServiceLoader.
      Type Parameters:
      T - the SPI extension type
      Parameters:
      loader - a service loader instance to find the singleton extension in
      Returns:
      an instance of the extension