private static Bundle readPluginBundle(final Set<Bundle> bundles, final Path plugin, String type) throws IOException { LogManager.getLogger(PluginsService.class).trace("--- adding [{}] [{}]", type, plugin.toAbsolutePath()); final PluginInfo info; try { info = PluginInfo.readFromProperties(plugin); } catch (final IOException e) { throw new IllegalStateException("Could not load plugin descriptor for " + type + " directory [" + plugin.getFileName() + "]", e); } final Bundle bundle = new Bundle(info, plugin); if (bundles.add(bundle) == false) { throw new IllegalStateException("duplicate " + type + ": " + info); } return bundle; }
if (bundles.add(new Bundle(info, urls)) == false) { throw new IllegalStateException("duplicate plugin: " + info);
throw new IllegalStateException("modules must be isolated: " + info); Bundle bundle = new Bundle(); bundle.plugins.add(info);
static Set<Bundle> getModuleBundles(Path modulesDirectory) throws IOException { // damn leniency if (Files.notExists(modulesDirectory)) { return Collections.emptySet(); } Set<Bundle> bundles = new LinkedHashSet<>(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(modulesDirectory)) { for (Path module : stream) { PluginInfo info = PluginInfo.readFromProperties(module); Set<URL> urls = new LinkedHashSet<>(); // gather urls for jar files try (DirectoryStream<Path> jarStream = Files.newDirectoryStream(module, "*.jar")) { for (Path jar : jarStream) { // normalize with toRealPath to get symlinks out of our hair URL url = jar.toRealPath().toUri().toURL(); if (urls.add(url) == false) { throw new IllegalStateException("duplicate codebase: " + url); } } } if (bundles.add(new Bundle(info, urls)) == false) { throw new IllegalStateException("duplicate module: " + info); } } } return bundles; }
private static Bundle readPluginBundle(final Set<Bundle> bundles, final Path plugin, String type) throws IOException { Loggers.getLogger(PluginsService.class).trace("--- adding [{}] [{}]", type, plugin.toAbsolutePath()); final PluginInfo info; try { info = PluginInfo.readFromProperties(plugin); } catch (final IOException e) { throw new IllegalStateException("Could not load plugin descriptor for " + type + " directory [" + plugin.getFileName() + "]", e); } final Bundle bundle = new Bundle(info, plugin); if (bundles.add(bundle) == false) { throw new IllegalStateException("duplicate " + type + ": " + info); } return bundle; }
private static Bundle readPluginBundle(final Set<Bundle> bundles, final Path plugin, String type) throws IOException { Loggers.getLogger(PluginsService.class).trace("--- adding [{}] [{}]", type, plugin.toAbsolutePath()); final PluginInfo info; try { info = PluginInfo.readFromProperties(plugin); } catch (final IOException e) { throw new IllegalStateException("Could not load plugin descriptor for " + type + " directory [" + plugin.getFileName() + "]", e); } final Bundle bundle = new Bundle(info, plugin); if (bundles.add(bundle) == false) { throw new IllegalStateException("duplicate " + type + ": " + info); } return bundle; }