Source:
public NotebookRepo loadNotebookRepo(String notebookRepoClassName) throws IOException { LOGGER.info("Loading NotebookRepo Plugin: " + notebookRepoClassName); String isTest = System.getenv("IS_ZEPPELIN_TEST"); if (isTest != null && isTest.equals("true")) { try { NotebookRepo notebookRepo = (NotebookRepo) (Class.forName(notebookRepoClassName).newInstance()); return notebookRepo; } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { LOGGER.warn("Fail to instantiate notebookrepo from classpath directly:" + notebookRepoClassName); } } String simpleClassName = notebookRepoClassName.substring(notebookRepoClassName.lastIndexOf(".") + 1); File pluginFolder = new File(pluginsDir + "/NotebookRepo/" + simpleClassName); if (!pluginFolder.exists() || pluginFolder.isFile()) { LOGGER.warn("pluginFolder " + pluginFolder.getAbsolutePath() + " doesn't exist or is not a directory"); return null; } List<URL> urls = new ArrayList<>(); for (File file : pluginFolder.listFiles()) { LOGGER.debug("Add file " + file.getAbsolutePath() + " to classpath of plugin " + notebookRepoClassName); urls.add(file.toURI().toURL()); } if (urls.isEmpty()) { LOGGER.warn("Can not load plugin " + notebookRepoClassName + ", because the plugin folder " + pluginFolder + " is empty."); return null; } URLClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[0])); Iterator<NotebookRepo> iter = ServiceLoader.load(NotebookRepo.class, classLoader).iterator(); NotebookRepo notebookRepo = iter.next(); if (notebookRepo == null) { LOGGER.warn("Unable to load NotebookRepo Plugin: " + notebookRepoClassName); } return notebookRepo; }

Target:
public NotebookRepo loadNotebookRepo(String notebookRepoClassName) throws IOException { LOGGER.info("Loading NotebookRepo Plugin: " + notebookRepoClassName); String isTest = System.getenv("IS_ZEPPELIN_TEST"); if (isTest != null && isTest.equals("true")) { try { NotebookRepo notebookRepo = (NotebookRepo) (Class.forName(notebookRepoClassName).newInstance()); return notebookRepo; } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { LOGGER.warn("Fail to instantiate notebookrepo from classpath directly:" + notebookRepoClassName, e); } } String simpleClassName = notebookRepoClassName.substring(notebookRepoClassName.lastIndexOf(".") + 1); File pluginFolder = new File(pluginsDir + "/NotebookRepo/" + simpleClassName); if (!pluginFolder.exists() || pluginFolder.isFile()) { LOGGER.warn("pluginFolder " + pluginFolder.getAbsolutePath() + " doesn't exist or is not a directory"); return null; } List<URL> urls = new ArrayList<>(); for (File file : pluginFolder.listFiles()) { LOGGER.debug("Add file " + file.getAbsolutePath() + " to classpath of plugin " + notebookRepoClassName); urls.add(file.toURI().toURL()); } if (urls.isEmpty()) { LOGGER.warn("Can not load plugin " + notebookRepoClassName + ", because the plugin folder " + pluginFolder + " is empty."); return null; } URLClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[0])); Iterator<NotebookRepo> iter = ServiceLoader.load(NotebookRepo.class, classLoader).iterator(); NotebookRepo notebookRepo = iter.next(); if (notebookRepo == null) { LOGGER.warn("Unable to load NotebookRepo Plugin: " + notebookRepoClassName); } return notebookRepo; }