public int compare(final Plugin plugin1, final Plugin plugin2) { int result = nameComparator.compare(plugin1, plugin2); if (result != 0) { return result; } result = plugin1.getKey().compareTo(plugin2.getKey()); if (result != 0) { return result; } result = plugin1.getPluginsVersion() - plugin2.getPluginsVersion(); if (result != 0) { return result; } return 0; } }
public Collection<Plugin> getPlugins() { final SortedSet<Plugin> plugins = new TreeSet<>(new PluginComparator()); for(Plugin plugin : pluginAccessor.getPlugins()) { if (!plugins.add(plugin)) { throw new IllegalStateException("Multiple plugins with the same key and version:" + plugin.getKey() + " " + plugin.getPluginsVersion()); } } return Collections.unmodifiableSet(plugins); }
protected Plugin loadPlugin(final ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException { final InputStream source = getSource(); if (source == null) { throw new PluginParseException("Invalid resource or inputstream specified to load plugins from."); } Plugin plugin; try { final DescriptorParser parser = descriptorParserFactory.getInstance(source, ImmutableSet.of()); plugin = parser.configurePlugin(moduleDescriptorFactory, getNewPlugin()); if (plugin.getPluginsVersion() == 2) { UnloadablePlugin unloadablePlugin = UnloadablePluginFactory.createUnloadablePlugin(plugin); final StringBuilder errorText = new StringBuilder("OSGi plugins cannot be deployed via the classpath, which is usually WEB-INF/lib."); if (resource != null) { errorText.append("\n Resource is: ").append(resource); } if (url != null) { errorText.append("\n URL is: ").append(url); } unloadablePlugin.setErrorText(errorText.toString()); plugin = unloadablePlugin; } } catch (final PluginParseException e) { throw new PluginParseException("Unable to load plugin resource: " + resource + " - " + e.getMessage(), e); } return plugin; }
void addPluginInformation(SupportInfoBuilder pluginBuilder, Plugin plugin) { PluginInformation pluginInformation = plugin.getPluginInformation(); pluginBuilder.addValue(PLUGIN_KEY, plugin.getKey()); pluginBuilder.addValue(PLUGIN_VERSION, pluginInformation.getVersion()); pluginBuilder.addValue(PLUGIN_VENDOR, pluginInformation.getVendorName()); pluginBuilder.addValue(PLUGIN_STATUS, plugin.getPluginState().toString()); pluginBuilder.addValue(PLUGIN_VENDOR_URL, pluginInformation.getVendorUrl()); pluginBuilder.addValue(PLUGIN_FRAMEWORK_VERSION, String.valueOf(plugin.getPluginsVersion())); pluginBuilder.addContext(plugin); }
private void loadPluginPropertiesIntoStore(final PropertyStore pluginPropertiesStore, final Collection<Plugin> pluginsCollection) { for (final Plugin plugin : pluginsCollection) { final PluginInformation pluginInformation = plugin.getPluginInformation(); final PropertyStore pluginStore = pluginPropertiesStore.addCategory(PLUGINS_PLUGIN); pluginStore.setValue(PLUGIN_KEY, plugin.getKey()); pluginStore.setValue(PLUGIN_NAME, plugin.getName()); // this is important for the SysInfo page pluginStore.setValue(PLUGIN_VERSION, pluginInformation.getVersion()); pluginStore.setValue(PLUGIN_VENDOR, pluginInformation.getVendorName()); pluginStore.setValue(PLUGIN_STATUS, plugin.getPluginState().toString()); pluginStore.setValue(PLUGIN_VENDOR_URL, pluginInformation.getVendorUrl()); pluginStore.setValue(PLUGIN_FRAMEWORK_VERSION, String.valueOf(plugin.getPluginsVersion())); pluginStore.setValue(PLUGIN_BUNDLED, plugin.isBundledPlugin() ? getText(PLUGIN_BUNDLED) : getText(PLUGIN_USER_INSTALLED)); } }
newPlugin.setUninstallable(oldPlugin.isUninstallable()); newPlugin.setDeletable(oldPlugin.isDeleteable()); newPlugin.setPluginsVersion(oldPlugin.getPluginsVersion()); newPlugin.setDynamicallyLoaded(oldPlugin.isDynamicallyLoaded());
private void addPluginInfo(final PropertyStore store) { callAndLogExceptions((Callable<Void>) () -> { Collection<Plugin> plugins = utils.getPlugins(); PluginMetadataManager pluginMetadataManager = ComponentManager.getComponent(PluginMetadataManager.class); PropertyStore pluginProperties = store.addCategory(AbstractSupportApplicationInfo.ENABLED_PLUGINS); for (Plugin plugin : plugins) { PluginInformation pluginInformation = plugin.getPluginInformation(); PropertyStore pluginStore = pluginProperties.addCategory(PLUGINS_PLUGIN); pluginStore.setValue(PLUGIN_KEY, plugin.getKey()); pluginStore.setValue(PLUGIN_NAME, plugin.getName()); pluginStore.setValue(PLUGIN_VERSION, pluginInformation.getVersion()); pluginStore.setValue(PLUGIN_VENDOR, pluginInformation.getVendorName()); pluginStore.setValue(PLUGIN_STATUS, plugin.getPluginState().toString()); pluginStore.setValue(PLUGIN_VENDOR_URL, pluginInformation.getVendorUrl()); pluginStore.setValue(PLUGIN_FRAMEWORK_VERSION, String.valueOf(plugin.getPluginsVersion())); pluginStore.setValue(PLUGIN_USER_INSTALLED, pluginMetadataManager.isUserInstalled(plugin) ? "true" : "false"); pluginStore.setValue(PLUGIN_BUNDLED, plugin.isBundledPlugin() ? getText(PLUGIN_BUNDLED) : getText(PLUGIN_USER_INSTALLED)); } return null; }); }