aboutsummaryrefslogtreecommitdiffstats
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-07-28 11:54:49 +0200
commit70c24eb376e514098f228bef76194536995c4957 (patch)
treed19d358e6ff39a23835dd7836fdbfbac448f2636 /sonar-core
parent1d155007f27ffaee6617cc2fd0cd41d7dcb0bff9 (diff)
downloadsonarqube-70c24eb376e514098f228bef76194536995c4957.tar.gz
sonarqube-70c24eb376e514098f228bef76194536995c4957.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 c3a28428141..9d2aa844adb 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
@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
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;
@@ -59,7 +59,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);
@@ -113,9 +113,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();
@@ -125,7 +125,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);
@@ -138,8 +138,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 fbeae3a2483..6242956e496 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
@@ -29,7 +29,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;
@@ -51,7 +50,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);
}