java.lang.Object
org.elasticsearch.plugins.ExtensionLoader
A utility for loading SPI extensions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Optional<T>
loadSingleton
(ServiceLoader<T> loader) Loads a single SPI extension.
-
Constructor Details
-
ExtensionLoader
public ExtensionLoader()
-
-
Method Details
-
loadSingleton
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 theuses
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
-