use of org.sonar.api.Plugin in project sonarqube by SonarSource.
the class ServerExtensionInstaller method installExtensions.
public void installExtensions(ComponentContainer container) {
ListMultimap<PluginInfo, Object> installedExtensionsByPlugin = ArrayListMultimap.create();
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
try {
String pluginKey = pluginInfo.getKey();
Plugin plugin = pluginRepository.getPluginInstance(pluginKey);
container.addExtension(pluginInfo, plugin);
Plugin.Context context = new Plugin.Context(sonarRuntime);
plugin.define(context);
for (Object extension : context.getExtensions()) {
if (installExtension(container, pluginInfo, extension, true) != null) {
installedExtensionsByPlugin.put(pluginInfo, extension);
} else {
container.declareExtension(pluginInfo, extension);
}
}
} catch (Throwable e) {
// catch Throwable because we want to catch Error too (IncompatibleClassChangeError, ...)
throw new IllegalStateException(String.format("Fail to load plugin %s [%s]", pluginInfo.getName(), pluginInfo.getKey()), e);
}
}
for (Map.Entry<PluginInfo, Object> entry : installedExtensionsByPlugin.entries()) {
PluginInfo pluginInfo = entry.getKey();
try {
Object extension = entry.getValue();
if (isExtensionProvider(extension)) {
ExtensionProvider provider = (ExtensionProvider) container.getComponentByKey(extension);
installProvider(container, pluginInfo, provider);
}
} catch (Throwable e) {
// catch Throwable because we want to catch Error too (IncompatibleClassChangeError, ...)
throw new IllegalStateException(String.format("Fail to load plugin %s [%s]", pluginInfo.getName(), pluginInfo.getKey()), e);
}
}
}
use of org.sonar.api.Plugin in project sonarqube by SonarSource.
the class I18nClassloader method allPluginClassloaders.
private static List<ClassLoader> allPluginClassloaders(PluginRepository pluginRepository) {
// accepted limitation: some plugins extend base plugins, sharing the same classloader, so
// there may be duplicated classloaders in the list.
List<ClassLoader> list = Lists.newArrayList();
for (PluginInfo info : pluginRepository.getPluginInfos()) {
Plugin plugin = pluginRepository.getPluginInstance(info.getKey());
list.add(plugin.getClass().getClassLoader());
}
list.add(I18nClassloader.class.getClassLoader());
return list;
}
use of org.sonar.api.Plugin in project sonarqube by SonarSource.
the class ExtensionInstaller method install.
public ExtensionInstaller install(ComponentContainer container, ExtensionMatcher matcher) {
// core components
for (Object o : BatchComponents.all(analysisMode)) {
doInstall(container, matcher, null, o);
}
// plugin extensions
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Plugin plugin = pluginRepository.getPluginInstance(pluginInfo.getKey());
Plugin.Context context = new Plugin.Context(sonarRuntime);
plugin.define(context);
for (Object extension : context.getExtensions()) {
doInstall(container, matcher, pluginInfo, extension);
}
}
List<ExtensionProvider> providers = container.getComponentsByType(ExtensionProvider.class);
for (ExtensionProvider provider : providers) {
Object object = provider.provide();
if (object instanceof Iterable) {
for (Object extension : (Iterable) object) {
doInstall(container, matcher, null, extension);
}
} else {
doInstall(container, matcher, null, object);
}
}
return this;
}
use of org.sonar.api.Plugin in project sonarqube by SonarSource.
the class GlobalContainer method installPlugins.
private void installPlugins() {
PluginRepository pluginRepository = getComponentByType(PluginRepository.class);
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Plugin instance = pluginRepository.getPluginInstance(pluginInfo.getKey());
addExtension(pluginInfo, instance);
}
}
use of org.sonar.api.Plugin in project sonarqube by SonarSource.
the class CePluginRepository method getPluginInstance.
@Override
public Plugin getPluginInstance(String key) {
checkState(started.get(), NOT_STARTED_YET);
Plugin plugin = pluginInstancesByKeys.get(key);
checkArgument(plugin != null, "Plugin [%s] does not exist", key);
return plugin;
}
Aggregations