Source:
public synchronized static <T> Collection<T> getFromExtensions(ExtensionsConfig config, Class<T> clazz) { final Set<T> retVal = Sets.newHashSet(); final Set<String> loadedExtensionNames = Sets.newHashSet(); if (config.searchCurrentClassloader()) { for (T module : ServiceLoader.load(clazz, Initialization.class.getClassLoader())) { String moduleName = module.getClass().getCanonicalName(); if (moduleName == null) { log.warn( "Extension module [%s] was ignored because it doesn't have a canonical name, is it a local or anonymous class?", module.getClass().getName() ); } else if (!loadedExtensionNames.contains(moduleName)) { log.info("Adding classpath extension module [%s] for class [%s]", moduleName, clazz.getName()); loadedExtensionNames.add(moduleName); retVal.add(module); } } } for (File extension : getExtensionFilesToLoad(config)) { log.info("Loading extension [%s] for class [%s]", extension.getName(), clazz.getName()); try { URLClassLoader loader = getClassLoaderForExtension(extension); for (T module : ServiceLoader.load(clazz, loader)) { String moduleName = module.getClass().getCanonicalName(); if (moduleName == null) { log.warn( "Extension module [%s] was ignored because it doesn't have a canonical name, is it a local or anonymous class?", module.getClass().getName() ); } else if (!loadedExtensionNames.contains(moduleName)) { log.info("Adding local file system extension module [%s] for class [%s]", moduleName, clazz.getName()); loadedExtensionNames.add(moduleName); retVal.add(module); } } } catch (Exception e) { throw Throwables.propagate(e); } } extensionsMap.put(clazz, retVal); return retVal; }

Target:
public synchronized static <T> Collection<T> getFromExtensions(ExtensionsConfig config, Class<T> clazz) { final Set<T> retVal = Sets.newHashSet(); final Set<String> loadedExtensionNames = Sets.newHashSet(); if (config.searchCurrentClassloader()) { for (T module : ServiceLoader.load(clazz, Thread.currentThread().getContextClassLoader())) { final String moduleName = module.getClass().getCanonicalName(); if (moduleName == null) { log.warn( "Extension module [%s] was ignored because it doesn't have a canonical name, is it a local or anonymous class?", module.getClass().getName() ); } else if (!loadedExtensionNames.contains(moduleName)) { log.info("Adding classpath extension module [%s] for class [%s]", moduleName, clazz.getName()); loadedExtensionNames.add(moduleName); retVal.add(module); } } } for (File extension : getExtensionFilesToLoad(config)) { log.info("Loading extension [%s] for class [%s]", extension.getName(), clazz.getName()); try { final URLClassLoader loader = getClassLoaderForExtension(extension); for (T module : ServiceLoader.load(clazz, loader)) { final String moduleName = module.getClass().getCanonicalName(); if (moduleName == null) { log.warn( "Extension module [%s] was ignored because it doesn't have a canonical name, is it a local or anonymous class?", module.getClass().getName() ); } else if (!loadedExtensionNames.contains(moduleName)) { log.info("Adding local file system extension module [%s] for class [%s]", moduleName, clazz.getName()); loadedExtensionNames.add(moduleName); retVal.add(module); } } } catch (Exception e) { throw Throwables.propagate(e); } } extensionsMap.put(clazz, retVal); return retVal; }