private static Plugin extractOsgiPlugin( final PluginArtifact pluginArtifact, final Manifest mf, final OsgiContainerManager osgi, final PluginEventManager pluginEventManager) { final String pluginKey = getNonEmptyAttribute(mf, OsgiPlugin.ATLASSIAN_PLUGIN_KEY); final String bundleName = getAttributeWithoutValidation(mf, Constants.BUNDLE_NAME); final Plugin plugin = new OsgiPlugin(pluginKey, osgi, pluginArtifact, pluginArtifact, pluginEventManager); plugin.setPluginsVersion(2); plugin.setName(bundleName); return plugin; }
public Plugin configurePlugin(final ModuleDescriptorFactory moduleDescriptorFactory, final Plugin plugin) throws PluginParseException { plugin.setName(descriptorReader.getPluginName()); plugin.setKey(getKey()); plugin.setPluginsVersion(getPluginsVersion()); plugin.setSystemPlugin(isSystemPlugin()); plugin.setI18nNameKey(descriptorReader.getI18nPluginNameKey().orElseGet(plugin::getI18nNameKey)); if (plugin.getKey().indexOf(":") > 0) { throw new PluginParseException("Plugin keys cannot contain ':'. Key is '" + plugin.getKey() + "'"); } plugin.setEnabledByDefault(descriptorReader.isEnabledByDefault()); plugin.setResources(descriptorReader.getResources()); plugin.setPluginInformation(createPluginInformation()); for (Element module : descriptorReader.getModules(plugin.getInstallationMode())) { final ModuleDescriptor<?> moduleDescriptor = createModuleDescriptor(plugin, module, moduleDescriptorFactory); // If we're not loading the module descriptor, null is returned, so we skip it if (moduleDescriptor == null) { continue; } if (plugin.getModuleDescriptor(moduleDescriptor.getKey()) != null) { throw new PluginParseException("Found duplicate key '" + moduleDescriptor.getKey() + "' within plugin '" + plugin.getKey() + "'"); } plugin.addModuleDescriptor(moduleDescriptor); // If we have any unloadable modules, also create an unloadable plugin, which will make it clear that there was a problem if (moduleDescriptor instanceof UnloadableModuleDescriptor) { log.error("There were errors loading the plugin '" + plugin.getName() + "'. The plugin has been disabled."); return UnloadablePluginFactory.createUnloadablePlugin(plugin); } } return plugin; }