private URLClassLoader buildClassLoader(String plugin) throws Exception { File file = new File(plugin); if (file.isFile() && (file.getName().equals("pom.xml") || file.getName().endsWith(".pom"))) { return buildClassLoaderFromPom(file); } if (file.isDirectory()) { return buildClassLoaderFromDirectory(file); } return buildClassLoaderFromCoordinates(plugin); }
private URLClassLoader buildClassLoaderFromDirectory(File dir) throws Exception { log.debug("Classpath for %s:", dir.getName()); List<URL> urls = new ArrayList<>(); for (File file : listFiles(dir)) { log.debug(" %s", file); urls.add(file.toURI().toURL()); } return createClassLoader(urls); }
@Override public void installPlugin(Plugin plugin) { pluginManager.installPlugin(plugin); }
public void loadPlugins() throws Exception { if (!pluginsLoading.compareAndSet(false, true)) { return; } for (File file : listFiles(installedPluginsDir)) { if (file.isDirectory()) { loadPlugin(file.getAbsolutePath()); } } for (String plugin : plugins) { loadPlugin(plugin); } metadata.verifyComparableOrderableContract(); pluginsLoaded.set(true); }
private void loadPlugin(String plugin) throws Exception { log.info("-- Loading plugin %s --", plugin); URLClassLoader pluginClassLoader = buildClassLoader(plugin); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(pluginClassLoader)) { loadPlugin(pluginClassLoader); } log.info("-- Finished loading plugin %s --", plugin); }
private URLClassLoader createClassLoader(List<Artifact> artifacts, String name) throws IOException { log.debug("Classpath for %s:", name); List<URL> urls = new ArrayList<>(); for (Artifact artifact : sortedArtifacts(artifacts)) { if (artifact.getFile() == null) { throw new RuntimeException("Could not resolve artifact: " + artifact); } File file = artifact.getFile().getCanonicalFile(); log.debug(" %s", file); urls.add(file.toURI().toURL()); } return createClassLoader(urls); }
private URLClassLoader buildClassLoaderFromCoordinates(String coordinates) throws Exception { Artifact rootArtifact = new DefaultArtifact(coordinates); List<Artifact> artifacts = resolver.resolveArtifacts(rootArtifact); return createClassLoader(artifacts, rootArtifact.toString()); }
Injector injector = app.strictConfig().initialize(); injector.getInstance(PluginManager.class).loadPlugins();
ImmutableSet.of()); this.pluginManager = new PluginManager( nodeInfo, new PluginManagerConfig(),
private void loadPlugin(String plugin) throws Exception { log.info("-- Loading plugin %s --", plugin); URLClassLoader pluginClassLoader = buildClassLoader(plugin); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(pluginClassLoader)) { loadPlugin(pluginClassLoader); } log.info("-- Finished loading plugin %s --", plugin); }
private URLClassLoader createClassLoader(List<Artifact> artifacts, String name) throws IOException { log.debug("Classpath for %s:", name); List<URL> urls = new ArrayList<>(); for (Artifact artifact : sortedArtifacts(artifacts)) { if (artifact.getFile() == null) { throw new RuntimeException("Could not resolve artifact: " + artifact); } File file = artifact.getFile().getCanonicalFile(); log.debug(" %s", file); urls.add(file.toURI().toURL()); } return createClassLoader(urls); }
public void loadPlugins() throws Exception { if (!pluginsLoading.compareAndSet(false, true)) { return; } for (File file : listFiles(installedPluginsDir)) { if (file.isDirectory()) { loadPlugin(file.getAbsolutePath()); } } for (String plugin : plugins) { loadPlugin(plugin); } metadata.verifyComparableOrderableContract(); pluginsLoaded.set(true); }
private URLClassLoader buildClassLoaderFromCoordinates(String coordinates) throws Exception { Artifact rootArtifact = new DefaultArtifact(coordinates); List<Artifact> artifacts = resolver.resolveArtifacts(rootArtifact); return createClassLoader(artifacts, rootArtifact.toString()); }
Injector injector = app.strictConfig().initialize(); injector.getInstance(PluginManager.class).loadPlugins();
ImmutableSet.of()); this.pluginManager = new PluginManager( nodeInfo, new PluginManagerConfig(),
private URLClassLoader buildClassLoader(String plugin) throws Exception { File file = new File(plugin); if (file.isFile() && (file.getName().equals("pom.xml") || file.getName().endsWith(".pom"))) { return buildClassLoaderFromPom(file); } if (file.isDirectory()) { return buildClassLoaderFromDirectory(file); } return buildClassLoaderFromCoordinates(plugin); }
private URLClassLoader buildClassLoaderFromDirectory(File dir) throws Exception { log.debug("Classpath for %s:", dir.getName()); List<URL> urls = new ArrayList<>(); for (File file : listFiles(dir)) { log.debug(" %s", file); urls.add(file.toURI().toURL()); } return createClassLoader(urls); }
public void installPlugin(Plugin plugin) { pluginManager.installPlugin(plugin); }
private URLClassLoader buildClassLoaderFromPom(File pomFile) throws Exception { List<Artifact> artifacts = resolver.resolvePom(pomFile); URLClassLoader classLoader = createClassLoader(artifacts, pomFile.getPath()); Artifact artifact = artifacts.get(0); Set<String> plugins = discoverPlugins(artifact, classLoader); if (!plugins.isEmpty()) { writePluginServices(plugins, artifact.getFile()); } return classLoader; }
@Override public void installPlugin(Plugin plugin) { pluginManager.installPlugin(plugin); }