Class ExtensionsLoader


  • public class ExtensionsLoader
    extends Object
    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.
    • Constructor Detail

      • ExtensionsLoader

        @Inject
        public ExtensionsLoader​(ExtensionsConfig config)
    • Method Detail

      • instance

        public static ExtensionsLoader instance​(com.google.inject.Injector injector)
      • 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.
      • getFromExtensions

        public <T> Collection<T> getFromExtensions​(Class<T> serviceClass)
        Look for implementations for the given class from both classpath and extensions directory, using ServiceLoader. 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().
      • 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
      • getURLsForClasspath

        public static List<URL> getURLsForClasspath​(String cp)