Package org.apache.druid.guice
Class ExtensionsLoader
java.lang.Object
org.apache.druid.guice.ExtensionsLoader
Manages the loading of Druid extensions. Used in two cases: for
CLI extensions from
Main, and for DruidModule
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.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExtensionsLoader(ExtensionsConfig config, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionconfig()getClassLoaderForExtension(File extension, boolean useExtensionClassloaderFirst) getClassLoaderForExtension(File extension, boolean useExtensionClassloaderFirst, List<String> extensionDependencyStack) File[]<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.voidFind all the extension files that should be loaded by druid.static ExtensionsLoaderinstance(com.google.inject.Injector injector)
-
Field Details
-
DRUID_EXTENSION_DEPENDENCIES_JSON
- See Also:
-
-
Constructor Details
-
ExtensionsLoader
@Inject public ExtensionsLoader(ExtensionsConfig config, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
instance
-
config
-
getLoadedImplementations
Returns a collection of implementations loaded.- Type Parameters:
T- the service type- Parameters:
clazz- service class
-
getLoadedModules
- Returns:
- a collection of implementations loaded.
-
getLoadersMap
-
getFromExtensions
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
-
initializeExtensionFilesToLoad
public void initializeExtensionFilesToLoad()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. -
getExtensionFilesToLoad
-
getClassLoaderForExtension
public StandardURLClassLoader getClassLoaderForExtension(File extension, boolean useExtensionClassloaderFirst) - Parameters:
extension- The File instance of the extension we want to load- Returns:
- a StandardURLClassLoader that loads all the jars on which the extension is dependent
-
getClassLoaderForExtension
public StandardURLClassLoader getClassLoaderForExtension(File extension, boolean useExtensionClassloaderFirst, List<String> extensionDependencyStack) - Parameters:
extension- The File instance of the extension we want to loaduseExtensionClassloaderFirst- Whether to return a StandardURLClassLoader that checks extension classloaders first for classesextensionDependencyStack- If the extension is requested as a dependency of another extension, a list containing the dependency stack of the dependent extension (for checking circular dependencies). Otherwise this is a empty list.- Returns:
- a StandardURLClassLoader that loads all the jars on which the extension is dependent
-
getURLsForClasspath
-