aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-29 10:29:04 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-05 09:54:04 +0200
commit0956511c8c9d6aa6639d4378f47d73877cdc18de (patch)
treec7a14388d2eec8a5f1f1d7d25fb48894ee4aae9f /sonar-batch
parentb1a02efd650918249cd828bd19f4ebf2118d8a79 (diff)
downloadsonarqube-0956511c8c9d6aa6639d4378f47d73877cdc18de.tar.gz
sonarqube-0956511c8c9d6aa6639d4378f47d73877cdc18de.zip
SONAR-6370 isolate plugin classloader from core classes
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/pom.xml4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginJarExploder.java (renamed from sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginExploder.java)6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginLoader.java41
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java7
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginJarExploderTest.java (renamed from sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginExploderTest.java)8
5 files changed, 16 insertions, 50 deletions
diff --git a/sonar-batch/pom.xml b/sonar-batch/pom.xml
index 668d8fd90fe..ee8f1407c83 100644
--- a/sonar-batch/pom.xml
+++ b/sonar-batch/pom.xml
@@ -28,6 +28,10 @@
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-persistit</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginExploder.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginJarExploder.java
index c08b9578786..e68dcb51a13 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginExploder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginJarExploder.java
@@ -23,7 +23,7 @@ import org.apache.commons.io.FileUtils;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.utils.ZipUtils;
import org.sonar.core.platform.ExplodedPlugin;
-import org.sonar.core.platform.PluginExploder;
+import org.sonar.core.platform.PluginJarExploder;
import org.sonar.core.platform.PluginInfo;
import org.sonar.home.cache.FileCache;
@@ -32,11 +32,11 @@ import java.io.FileOutputStream;
import java.io.IOException;
@BatchSide
-public class BatchPluginExploder extends PluginExploder {
+public class BatchPluginJarExploder extends PluginJarExploder {
private final FileCache fileCache;
- public BatchPluginExploder(FileCache fileCache) {
+ public BatchPluginJarExploder(FileCache fileCache) {
this.fileCache = fileCache;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginLoader.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginLoader.java
deleted file mode 100644
index 8ffbc98b410..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginLoader.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.bootstrap;
-
-import org.sonar.api.batch.BatchSide;
-import org.sonar.core.platform.PluginExploder;
-import org.sonar.core.platform.PluginLoader;
-
-/**
- * The {@link PluginLoader} on batch side requires to use thread context
- * classloader as base classloader in order to support plugins like Groovy
- * (at least its version 1.1).
- */
-@BatchSide
-public class BatchPluginLoader extends PluginLoader {
- public BatchPluginLoader(PluginExploder exploder) {
- super(exploder);
- }
-
- @Override
- protected ClassLoader baseClassloader() {
- return Thread.currentThread().getContextClassLoader();
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
index facf6c58a3a..2e1542ada81 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
@@ -54,7 +54,9 @@ import org.sonar.core.persistence.MyBatis;
import org.sonar.core.persistence.SemaphoreUpdater;
import org.sonar.core.persistence.SemaphoresImpl;
import org.sonar.core.platform.ComponentContainer;
+import org.sonar.core.platform.PluginClassloaderFactory;
import org.sonar.core.platform.PluginInfo;
+import org.sonar.core.platform.PluginLoader;
import org.sonar.core.platform.PluginRepository;
import org.sonar.core.purge.PurgeProfiler;
import org.sonar.core.rule.CacheRuleFinder;
@@ -98,8 +100,9 @@ public class GlobalContainer extends ComponentContainer {
add(
// plugins
BatchPluginRepository.class,
- BatchPluginLoader.class,
- BatchPluginExploder.class,
+ PluginLoader.class,
+ PluginClassloaderFactory.class,
+ BatchPluginJarExploder.class,
BatchPluginPredicate.class,
ExtensionInstaller.class,
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginExploderTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginJarExploderTest.java
index f2c2f6354a3..bb678103fe2 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginExploderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginJarExploderTest.java
@@ -34,19 +34,19 @@ import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
-public class BatchPluginExploderTest {
+public class BatchPluginJarExploderTest {
@ClassRule
public static TemporaryFolder temp = new TemporaryFolder();
File userHome;
- BatchPluginExploder underTest;
+ BatchPluginJarExploder underTest;
@Before
public void setUp() throws IOException {
userHome = temp.newFolder();
FileCache fileCache = new FileCacheBuilder().setUserHome(userHome).build();
- underTest = new BatchPluginExploder(fileCache);
+ underTest = new BatchPluginJarExploder(fileCache);
}
@Test
@@ -72,7 +72,7 @@ public class BatchPluginExploderTest {
}
File getFileFromCache(String filename) throws IOException {
- File src = FileUtils.toFile(BatchPluginExploderTest.class.getResource("/org/sonar/batch/bootstrap/BatchPluginUnzipperTest/" + filename));
+ File src = FileUtils.toFile(BatchPluginJarExploderTest.class.getResource("/org/sonar/batch/bootstrap/BatchPluginUnzipperTest/" + filename));
File destFile = new File(new File(userHome, "" + filename.hashCode()), filename);
FileUtils.copyFile(src, destFile);
return destFile;