summaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-07-27 17:39:34 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-09-04 10:50:05 +0200
commit692d67c831857cb13207ae2ecee14753b4e419c7 (patch)
treef98604346eef80ccd74a0c12950928a7ac9ef97a /sonar-core
parent874e8fdfd7cb902181914fc236c9ab46f15c8a1b (diff)
downloadsonarqube-692d67c831857cb13207ae2ecee14753b4e419c7.tar.gz
sonarqube-692d67c831857cb13207ae2ecee14753b4e419c7.zip
SONAR-6746 Drop Plugin interface + batch cleanup
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/PluginRepository.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java3
4 files changed, 12 insertions, 13 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java b/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
index 4020f09ffaf..2aebd74e24e 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
@@ -24,7 +24,7 @@ import com.google.common.collect.Lists;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.List;
-import org.sonar.api.Plugin;
+import org.sonar.api.SonarPlugin;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginRepository;
@@ -71,7 +71,7 @@ class I18nClassloader extends URLClassLoader {
// there may be duplicated classloaders in the list.
List<ClassLoader> list = Lists.newArrayList();
for (PluginInfo info : pluginRepository.getPluginInfos()) {
- Plugin plugin = pluginRepository.getPluginInstance(info.getKey());
+ SonarPlugin plugin = pluginRepository.getPluginInstance(info.getKey());
list.add(plugin.getClass().getClassLoader());
}
list.add(I18nClassloader.class.getClassLoader());
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java b/sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java
index d77de10243e..2118a0dc1e4 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java
@@ -28,7 +28,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.SystemUtils;
-import org.sonar.api.Plugin;
+import org.sonar.api.SonarPlugin;
import org.sonar.api.utils.log.Loggers;
import org.sonar.updatecenter.common.Version;
@@ -67,7 +67,7 @@ public class PluginLoader {
this.classloaderFactory = classloaderFactory;
}
- public Map<String, Plugin> load(Map<String, PluginInfo> infoByKeys) {
+ public Map<String, SonarPlugin> load(Map<String, PluginInfo> infoByKeys) {
Collection<PluginClassLoaderDef> defs = defineClassloaders(infoByKeys);
Map<PluginClassLoaderDef, ClassLoader> classloaders = classloaderFactory.create(defs);
return instantiatePluginClasses(classloaders);
@@ -126,9 +126,9 @@ public class PluginLoader {
* @throws IllegalStateException if at least one plugin can't be correctly loaded
*/
@VisibleForTesting
- Map<String, Plugin> instantiatePluginClasses(Map<PluginClassLoaderDef, ClassLoader> classloaders) {
+ Map<String, SonarPlugin> instantiatePluginClasses(Map<PluginClassLoaderDef, ClassLoader> classloaders) {
// instantiate plugins
- Map<String, Plugin> instancesByPluginKey = new HashMap<>();
+ Map<String, SonarPlugin> instancesByPluginKey = new HashMap<>();
for (Map.Entry<PluginClassLoaderDef, ClassLoader> entry : classloaders.entrySet()) {
PluginClassLoaderDef def = entry.getKey();
ClassLoader classLoader = entry.getValue();
@@ -138,7 +138,7 @@ public class PluginLoader {
String pluginKey = mainClassEntry.getKey();
String mainClass = mainClassEntry.getValue();
try {
- instancesByPluginKey.put(pluginKey, (Plugin) classLoader.loadClass(mainClass).newInstance());
+ instancesByPluginKey.put(pluginKey, (SonarPlugin) classLoader.loadClass(mainClass).newInstance());
} catch (UnsupportedClassVersionError e) {
throw new IllegalStateException(String.format("The plugin [%s] does not support Java %s",
pluginKey, SystemUtils.JAVA_VERSION_TRIMMED), e);
@@ -151,8 +151,8 @@ public class PluginLoader {
return instancesByPluginKey;
}
- public void unload(Collection<Plugin> plugins) {
- for (Plugin plugin : plugins) {
+ public void unload(Collection<SonarPlugin> plugins) {
+ for (SonarPlugin plugin : plugins) {
ClassLoader classLoader = plugin.getClass().getClassLoader();
if (classLoader instanceof Closeable && classLoader != classloaderFactory.baseClassLoader()) {
try {
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/PluginRepository.java b/sonar-core/src/main/java/org/sonar/core/platform/PluginRepository.java
index 8457d391f9c..836523abce8 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/PluginRepository.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/PluginRepository.java
@@ -20,7 +20,7 @@
package org.sonar.core.platform;
import java.util.Collection;
-import org.sonar.api.Plugin;
+import org.sonar.api.SonarPlugin;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.server.ServerSide;
@@ -38,7 +38,7 @@ public interface PluginRepository {
/**
* @return the instance of {@link Plugin} for the given plugin key. Never return null.
*/
- Plugin getPluginInstance(String key);
+ SonarPlugin getPluginInstance(String key);
boolean hasPlugin(String key);
}
diff --git a/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java b/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java
index c79cccc04f0..34c0e76c1e9 100644
--- a/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java
@@ -30,7 +30,6 @@ import org.assertj.core.data.MapEntry;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.updatecenter.common.Version;
@@ -52,7 +51,7 @@ public class PluginLoaderTest {
PluginClassLoaderDef def = new PluginClassLoaderDef("fake");
def.addMainClass("fake", FakePlugin.class.getName());
- Map<String, Plugin> instances = loader.instantiatePluginClasses(ImmutableMap.of(def, getClass().getClassLoader()));
+ Map<String, SonarPlugin> instances = loader.instantiatePluginClasses(ImmutableMap.of(def, getClass().getClassLoader()));
assertThat(instances).containsOnlyKeys("fake");
assertThat(instances.get("fake")).isInstanceOf(FakePlugin.class);
}