Package org.apache.druid.guice
Class ExtensionsLoader
- java.lang.Object
-
- org.apache.druid.guice.ExtensionsLoader
-
public class ExtensionsLoader extends Object
Manages the loading of Druid extensions. Used in two cases: for CLI extensions fromMain
, and forDruidModule
extensions during initialization. The design, however, should support any kind of extension that may be needed in the future. The extensions are cached so that they can be reported by various REST APIs.
-
-
Constructor Summary
Constructors Constructor Description ExtensionsLoader(ExtensionsConfig config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExtensionsConfig
config()
URLClassLoader
getClassLoaderForExtension(File extension, boolean useExtensionClassloaderFirst)
File[]
getExtensionFilesToLoad()
Find all the extension files that should be loaded by druid.<T> Collection<T>
getFromExtensions(Class<T> serviceClass)
Look for implementations for the given class from both classpath and extensions directory, usingServiceLoader
.<T> Collection<T>
getLoadedImplementations(Class<T> clazz)
Returns a collection of implementations loaded.Collection<DruidModule>
getLoadedModules()
Map<Pair<File,Boolean>,URLClassLoader>
getLoadersMap()
Collection<DruidModule>
getModules()
static List<URL>
getURLsForClasspath(String cp)
static ExtensionsLoader
instance(com.google.inject.Injector injector)
-
-
-
Constructor Detail
-
ExtensionsLoader
@Inject public ExtensionsLoader(ExtensionsConfig config)
-
-
Method Detail
-
instance
public static ExtensionsLoader instance(com.google.inject.Injector injector)
-
config
public ExtensionsConfig config()
-
getLoadedImplementations
public <T> Collection<T> getLoadedImplementations(Class<T> clazz)
Returns a collection of implementations loaded.- Type Parameters:
T
- the service type- Parameters:
clazz
- service class
-
getLoadedModules
public Collection<DruidModule> getLoadedModules()
- Returns:
- a collection of implementations loaded.
-
getLoadersMap
public Map<Pair<File,Boolean>,URLClassLoader> getLoadersMap()
-
getFromExtensions
public <T> Collection<T> getFromExtensions(Class<T> serviceClass)
Look for implementations for the given class from both classpath and extensions directory, usingServiceLoader
. A user should never put the same two extensions in classpath and extensions directory, if he/she does that, the one that is in the classpath will be loaded, the other will be ignored.- Parameters:
serviceClass
- The class to look the implementations of (e.g., DruidModule)- Returns:
- A collection that contains implementations (of distinct concrete classes) of the given class. The order of elements in the returned collection is not specified and not guaranteed to be the same for different calls to getFromExtensions().
-
getModules
public Collection<DruidModule> getModules()
-
getExtensionFilesToLoad
public File[] getExtensionFilesToLoad()
Find all the extension files that should be loaded by druid. If user explicitly specifies druid.extensions.loadList, then it will look for those extensions under root extensions directory. If one of them is not found, druid will fail loudly. If user doesn't specify druid.extension.toLoad (or its value is empty), druid will load all the extensions under the root extensions directory.- Returns:
- an array of druid extension files that will be loaded by druid process
-
getClassLoaderForExtension
public URLClassLoader getClassLoaderForExtension(File extension, boolean useExtensionClassloaderFirst)
- Parameters:
extension
- The File instance of the extension we want to load- Returns:
- a URLClassLoader that loads all the jars on which the extension is dependent
-
-