]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10690 remove support for privileged plugins
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 30 May 2018 11:41:01 +0000 (13:41 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 12 Jun 2018 18:21:03 +0000 (20:21 +0200)
20 files changed:
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/PrivilegedPluginBridge.java [deleted file]
server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionBootstraper.java [new file with mode: 0644]
server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionBridge.java [new file with mode: 0644]
server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionStopper.java [new file with mode: 0644]
server/sonar-server-common/src/main/java/org/sonar/server/extension/package-info.java [new file with mode: 0644]
server/sonar-server-common/src/test/java/org/sonar/server/extension/CoreExtensionBootstraperTest.java [new file with mode: 0644]
server/sonar-server-common/src/test/java/org/sonar/server/extension/CoreExtensionStopperTest.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraper.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopper.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/package-info.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraperTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopperTest.java [deleted file]
sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoaderDef.java
sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java
sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java
sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java
tests/plugins/fake-billing-plugin/src/main/java/FakeBillingPlugin.java
tests/plugins/fake-governance-plugin/src/main/java/FakeGovernancePlugin.java

index 2a9888cfe2e64c9876b5074be92dec864dc336a6..1c45927fa2b7e312895c5679d2dd076c08b02693 100644 (file)
@@ -95,6 +95,8 @@ import org.sonar.server.debt.DebtRulesXMLImporter;
 import org.sonar.server.es.EsModule;
 import org.sonar.server.es.ProjectIndexersImpl;
 import org.sonar.server.event.NewAlerts;
+import org.sonar.server.extension.CoreExtensionBootstraper;
+import org.sonar.server.extension.CoreExtensionStopper;
 import org.sonar.server.favorite.FavoriteUpdater;
 import org.sonar.server.issue.IssueFieldsSetter;
 import org.sonar.server.issue.index.IssueIndex;
@@ -146,8 +148,6 @@ import org.sonar.server.platform.monitoring.OfficialDistribution;
 import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
 import org.sonar.server.plugins.InstalledPluginReferentialFactory;
 import org.sonar.server.plugins.ServerExtensionInstaller;
-import org.sonar.server.plugins.privileged.PrivilegedPluginsBootstraper;
-import org.sonar.server.plugins.privileged.PrivilegedPluginsStopper;
 import org.sonar.server.property.InternalPropertiesImpl;
 import org.sonar.server.qualitygate.QualityGateModule;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
@@ -443,8 +443,8 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
 
       // privileged plugins
       CECoreExtensionsInstaller.class,
-      PrivilegedPluginsBootstraper.class,
-      PrivilegedPluginsStopper.class,
+      CoreExtensionBootstraper.class,
+      CoreExtensionStopper.class,
 
       // Compute engine (must be after Views and Developer Cockpit)
       CeConfigurationModule.class,
diff --git a/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/PrivilegedPluginBridge.java b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/PrivilegedPluginBridge.java
deleted file mode 100644 (file)
index 308acec..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.plugin;
-
-import org.sonar.core.platform.ComponentContainer;
-
-/**
- * Interface implemented by the Extension point exposed by the Privileged plugin that serves as the unique access
- * point from the whole SQ instance into the Privileged plugin.
- */
-public interface PrivilegedPluginBridge {
-
-  String getPluginName();
-
-  /**
-   * Bootstraps the plugin.
-   *
-   * @param parent the parent ComponentContainer which provides Platform components for the Privileged plugin to use.
-   *
-   * @throws IllegalStateException if called more than once
-   */
-  void startPlugin(ComponentContainer parent);
-
-  /**
-   * This method is called when Platform is shutting down.
-   */
-  void stopPlugin();
-
-}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionBootstraper.java b/server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionBootstraper.java
new file mode 100644 (file)
index 0000000..cef03ab
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.extension;
+
+import java.util.List;
+import org.sonar.api.platform.Server;
+import org.sonar.api.platform.ServerStartHandler;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.api.utils.log.Profiler;
+import org.sonar.core.platform.ComponentContainer;
+
+import static java.lang.String.format;
+
+/**
+ * Startup task responsible to bootstrap installed Core Extensions (if any).
+ */
+public class CoreExtensionBootstraper implements ServerStartHandler {
+  private static final Logger LOGGER = Loggers.get(CoreExtensionBootstraper.class);
+
+  private final ComponentContainer componentContainer;
+
+  public CoreExtensionBootstraper(ComponentContainer componentContainer) {
+    this.componentContainer = componentContainer;
+  }
+
+  @Override
+  public void onServerStart(Server server) {
+    List<CoreExtensionBridge> bridges = componentContainer.getComponentsByType(CoreExtensionBridge.class);
+    for (CoreExtensionBridge bridge : bridges) {
+      Profiler profiler = Profiler.create(LOGGER).startInfo(format("Bootstrapping %s", bridge.getPluginName()));
+      bridge.startPlugin(componentContainer);
+      profiler.stopInfo();
+    }
+  }
+
+}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionBridge.java b/server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionBridge.java
new file mode 100644 (file)
index 0000000..008f0f9
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.extension;
+
+import org.sonar.core.platform.ComponentContainer;
+
+/**
+ * Interface implemented by the Extension point exposed by the Core Extensions that serves as the unique access
+ * point from the whole SQ instance into the Core Extension.
+ */
+public interface CoreExtensionBridge {
+
+  String getPluginName();
+
+  /**
+   * Bootstraps the plugin.
+   *
+   * @param parent the parent ComponentContainer which provides Platform components for the Privileged plugin to use.
+   *
+   * @throws IllegalStateException if called more than once
+   */
+  void startPlugin(ComponentContainer parent);
+
+  /**
+   * This method is called when Platform is shutting down.
+   */
+  void stopPlugin();
+
+}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionStopper.java b/server/sonar-server-common/src/main/java/org/sonar/server/extension/CoreExtensionStopper.java
new file mode 100644 (file)
index 0000000..17e61da
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.extension;
+
+import java.util.List;
+import org.picocontainer.Startable;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.api.utils.log.Profiler;
+import org.sonar.core.platform.ComponentContainer;
+
+import static java.lang.String.format;
+
+/**
+ * As an component of PlatformLevel4, this class is responsible for notifying shutdown to the installed Core Extensions
+ * (if any).
+ */
+public class CoreExtensionStopper implements Startable {
+  private static final Logger LOGGER = Loggers.get(CoreExtensionStopper.class);
+
+  private final ComponentContainer platformContainer;
+
+  public CoreExtensionStopper(ComponentContainer platformContainer) {
+    this.platformContainer = platformContainer;
+  }
+
+  @Override
+  public void start() {
+    // nothing to do, privileged plugins are started by CoreExtensionBootstraper
+  }
+
+  @Override
+  public void stop() {
+    List<CoreExtensionBridge> bridges = platformContainer.getComponentsByType(CoreExtensionBridge.class);
+    for (CoreExtensionBridge bridge : bridges) {
+      Profiler profiler = Profiler.create(LOGGER).startInfo(format("Stopping %s", bridge.getPluginName()));
+      bridge.stopPlugin();
+      profiler.stopInfo();
+    }
+  }
+}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/extension/package-info.java b/server/sonar-server-common/src/main/java/org/sonar/server/extension/package-info.java
new file mode 100644 (file)
index 0000000..92fa11f
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.extension;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/extension/CoreExtensionBootstraperTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/extension/CoreExtensionBootstraperTest.java
new file mode 100644 (file)
index 0000000..3b6029e
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.extension;
+
+import org.junit.Test;
+import org.sonar.api.platform.Server;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+public class CoreExtensionBootstraperTest {
+  private ComponentContainer componentContainer = new ComponentContainer();
+  private CoreExtensionBridge bridge = mock(CoreExtensionBridge.class);
+
+  private CoreExtensionBootstraper underTest = new CoreExtensionBootstraper(componentContainer);
+
+  @Test
+  public void onServerStart_calls_startPlugin_if_Bridge_exists_in_container() {
+    componentContainer.add(bridge);
+    componentContainer.startComponents();
+
+    underTest.onServerStart(mock(Server.class));
+
+    verify(bridge).getPluginName();
+    verify(bridge).startPlugin(componentContainer);
+    verifyNoMoreInteractions(bridge);
+  }
+
+  @Test
+  public void onServerStart_does_not_call_startPlugin_if_Bridge_does_not_exist_in_container() {
+    underTest.onServerStart(mock(Server.class));
+
+    verifyNoMoreInteractions(bridge);
+  }
+}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/extension/CoreExtensionStopperTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/extension/CoreExtensionStopperTest.java
new file mode 100644 (file)
index 0000000..4f6b791
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.extension;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+public class CoreExtensionStopperTest {
+  private ComponentContainer componentContainer = new ComponentContainer();
+  private CoreExtensionBridge bridge = mock(CoreExtensionBridge.class);
+
+  private CoreExtensionStopper underTest = new CoreExtensionStopper(componentContainer);
+
+  @Test
+  public void stop_calls_stopPlugin_if_Bridge_exists_in_container() {
+    componentContainer.add(bridge);
+    componentContainer.startComponents();
+
+    underTest.stop();
+
+    verify(bridge).getPluginName();
+    verify(bridge).stopPlugin();
+    verifyNoMoreInteractions(bridge);
+  }
+
+  @Test
+  public void stop_does_not_call_stopPlugin_if_Bridge_does_not_exist_in_container() {
+    underTest.stop();
+
+    verifyNoMoreInteractions(bridge);
+  }
+}
index 2794fc763c2e29a889098a2e9a114a90aeb5f089..fa23da44099bcfedf87473db47d88dac85266def 100644 (file)
@@ -67,6 +67,8 @@ import org.sonar.server.es.metadata.EsDbCompatibilityImpl;
 import org.sonar.server.es.metadata.MetadataIndex;
 import org.sonar.server.es.metadata.MetadataIndexDefinition;
 import org.sonar.server.event.NewAlerts;
+import org.sonar.server.extension.CoreExtensionBootstraper;
+import org.sonar.server.extension.CoreExtensionStopper;
 import org.sonar.server.favorite.FavoriteModule;
 import org.sonar.server.health.NodeHealthModule;
 import org.sonar.server.issue.AddTagsAction;
@@ -137,8 +139,6 @@ import org.sonar.server.platform.ws.UpgradesAction;
 import org.sonar.server.plugins.PluginDownloader;
 import org.sonar.server.plugins.PluginUninstaller;
 import org.sonar.server.plugins.ServerExtensionInstaller;
-import org.sonar.server.plugins.privileged.PrivilegedPluginsBootstraper;
-import org.sonar.server.plugins.privileged.PrivilegedPluginsStopper;
 import org.sonar.server.plugins.ws.AvailableAction;
 import org.sonar.server.plugins.ws.CancelAllAction;
 import org.sonar.server.plugins.ws.DownloadAction;
@@ -535,10 +535,10 @@ public class PlatformLevel4 extends PlatformLevel {
       // Project badges
       ProjectBadgesWsModule.class,
 
-      // privileged plugins
+      // Core Extensions
       WebCoreExtensionsInstaller.class,
-      PrivilegedPluginsBootstraper.class,
-      PrivilegedPluginsStopper.class,
+      CoreExtensionBootstraper.class,
+      CoreExtensionStopper.class,
 
       // Compute engine (must be after Views and Developer Cockpit)
       ReportAnalysisFailureNotificationModule.class,
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraper.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraper.java
deleted file mode 100644 (file)
index 8a15ce0..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.plugins.privileged;
-
-import java.util.List;
-import org.sonar.api.platform.Server;
-import org.sonar.api.platform.ServerStartHandler;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.api.utils.log.Profiler;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.plugin.PrivilegedPluginBridge;
-
-import static java.lang.String.format;
-
-/**
- * Startup task to responsible to bootstrap installed Privileged plugins (if any).
- */
-public class PrivilegedPluginsBootstraper implements ServerStartHandler {
-  private static final Logger LOGGER = Loggers.get(PrivilegedPluginsBootstraper.class);
-
-  private final ComponentContainer componentContainer;
-
-  public PrivilegedPluginsBootstraper(ComponentContainer componentContainer) {
-    this.componentContainer = componentContainer;
-  }
-
-  @Override
-  public void onServerStart(Server server) {
-    List<PrivilegedPluginBridge> bridges = componentContainer.getComponentsByType(PrivilegedPluginBridge.class);
-    for (PrivilegedPluginBridge bridge : bridges) {
-      Profiler profiler = Profiler.create(LOGGER).startInfo(format("Bootstrapping %s", bridge.getPluginName()));
-      bridge.startPlugin(componentContainer);
-      profiler.stopInfo();
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopper.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopper.java
deleted file mode 100644 (file)
index 3ca8e6d..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.plugins.privileged;
-
-import java.util.List;
-import org.picocontainer.Startable;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.api.utils.log.Profiler;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.plugin.PrivilegedPluginBridge;
-
-import static java.lang.String.format;
-
-/**
- * As an component of PlatformLevel4, this class is responsible for notifying shutdown to the installed Privileged plugins
- * (if any) when its installed.
- */
-public class PrivilegedPluginsStopper implements Startable {
-  private static final Logger LOGGER = Loggers.get(PrivilegedPluginsStopper.class);
-
-  private final ComponentContainer platformContainer;
-
-  public PrivilegedPluginsStopper(ComponentContainer platformContainer) {
-    this.platformContainer = platformContainer;
-  }
-
-  @Override
-  public void start() {
-    // nothing to do, privileged plugins are started by PrivilegedPluginsBootstraper
-  }
-
-  @Override
-  public void stop() {
-    List<PrivilegedPluginBridge> bridges = platformContainer.getComponentsByType(PrivilegedPluginBridge.class);
-    for (PrivilegedPluginBridge bridge : bridges) {
-      Profiler profiler = Profiler.create(LOGGER).startInfo(format("Stopping %s", bridge.getPluginName()));
-      bridge.stopPlugin();
-      profiler.stopInfo();
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/package-info.java
deleted file mode 100644 (file)
index 3f2755b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.server.plugins.privileged;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraperTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraperTest.java
deleted file mode 100644 (file)
index a68faa9..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.plugins.privileged;
-
-import org.junit.Test;
-import org.sonar.api.platform.Server;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.plugin.PrivilegedPluginBridge;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class PrivilegedPluginsBootstraperTest {
-  private ComponentContainer componentContainer = new ComponentContainer();
-  private PrivilegedPluginBridge bridge = mock(PrivilegedPluginBridge.class);
-
-  private PrivilegedPluginsBootstraper underTest = new PrivilegedPluginsBootstraper(componentContainer);
-
-  @Test
-  public void onServerStart_calls_startPlugin_if_Bridge_exists_in_container() {
-    componentContainer.add(bridge);
-    componentContainer.startComponents();
-
-    underTest.onServerStart(mock(Server.class));
-
-    verify(bridge).getPluginName();
-    verify(bridge).startPlugin(componentContainer);
-    verifyNoMoreInteractions(bridge);
-  }
-
-  @Test
-  public void onServerStart_does_not_call_startPlugin_if_Bridge_does_not_exist_in_container() {
-    underTest.onServerStart(mock(Server.class));
-
-    verifyNoMoreInteractions(bridge);
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopperTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopperTest.java
deleted file mode 100644 (file)
index c54505e..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.plugins.privileged;
-
-import org.junit.Test;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.plugin.PrivilegedPluginBridge;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class PrivilegedPluginsStopperTest {
-  private ComponentContainer componentContainer = new ComponentContainer();
-  private PrivilegedPluginBridge bridge = mock(PrivilegedPluginBridge.class);
-
-  private PrivilegedPluginsStopper underTest = new PrivilegedPluginsStopper(componentContainer);
-
-  @Test
-  public void stop_calls_stopPlugin_if_Bridge_exists_in_container() {
-    componentContainer.add(bridge);
-    componentContainer.startComponents();
-
-    underTest.stop();
-
-    verify(bridge).getPluginName();
-    verify(bridge).stopPlugin();
-    verifyNoMoreInteractions(bridge);
-  }
-
-  @Test
-  public void stop_does_not_call_stopPlugin_if_Bridge_does_not_exist_in_container() {
-    underTest.stop();
-
-    verifyNoMoreInteractions(bridge);
-  }
-}
index f89683ce43a8fb7ff3bf69e22f4d28f2f9513d63..c1c3584b58a6fafe210573b8e87caab1d84dcfd7 100644 (file)
@@ -46,8 +46,6 @@ class PluginClassLoaderDef {
    */
   private boolean compatibilityMode = false;
 
-  private boolean privileged = false;
-
   PluginClassLoaderDef(String basePluginKey) {
     Preconditions.checkArgument(!Strings.isNullOrEmpty(basePluginKey));
     this.basePluginKey = basePluginKey;
@@ -95,14 +93,6 @@ class PluginClassLoaderDef {
     this.compatibilityMode = b;
   }
 
-  boolean isPrivileged() {
-    return privileged;
-  }
-
-  void setPrivileged(boolean privileged) {
-    this.privileged = privileged;
-  }
-
   @Override
   public boolean equals(@Nullable Object o) {
     if (this == o) {
index 0706050feaddbf67735b0c395f1ca4bd675be4c9..0c69f978a096ae97509e1a260585b2a3d1849e39 100644 (file)
@@ -73,11 +73,7 @@ public class PluginClassloaderFactory {
 
     for (PluginClassLoaderDef def : defs) {
       builder.newClassloader(def.getBasePluginKey());
-      if (def.isPrivileged()) {
-        builder.setParent(def.getBasePluginKey(), baseClassLoader, new Mask());
-      } else {
-        builder.setParent(def.getBasePluginKey(), API_CLASSLOADER_KEY, new Mask());
-      }
+      builder.setParent(def.getBasePluginKey(), API_CLASSLOADER_KEY, new Mask());
       builder.setLoadingOrder(def.getBasePluginKey(), def.isSelfFirstStrategy() ? SELF_FIRST : PARENT_FIRST);
       for (File jar : def.getFiles()) {
         builder.addURL(def.getBasePluginKey(), fileToUrl(jar));
index 593adca7a73412a571c2bc4b3790caa0ff85b7d7..f44a346336ea72755d2008d88a8d258e217c4116 100644 (file)
@@ -24,16 +24,13 @@ import com.google.common.base.Strings;
 import java.io.Closeable;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 import org.apache.commons.lang.SystemUtils;
 import org.sonar.api.Plugin;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.updatecenter.common.Version;
 
 import static java.util.Arrays.asList;
-import static java.util.Collections.unmodifiableSet;
 
 /**
  * Loads the plugin JAR files by creating the appropriate classloaders and by instantiating
@@ -52,11 +49,6 @@ import static java.util.Collections.unmodifiableSet;
 public class PluginLoader {
 
   private static final String[] DEFAULT_SHARED_RESOURCES = {"org/sonar/plugins", "com/sonar/plugins", "com/sonarsource/plugins"};
-  /**
-   * Defines the base keys (defined by {@link #basePluginKey(PluginInfo, Map)}) of the plugins which are allowed to
-   * run a full server extensions.
-   */
-  private static final Set<String> PRIVILEGED_PLUGINS_BASE_KEYS = unmodifiableSet(new HashSet<>(asList("billing", "branch", "developer", "governance", "ha", "license")));
 
   public static final Version COMPATIBILITY_MODE_MAX_VERSION = Version.create("5.2");
 
@@ -105,7 +97,6 @@ public class PluginLoader {
         Version minSqVersion = info.getMinimalSqVersion();
         boolean compatibilityMode = minSqVersion != null && minSqVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0;
         def.setCompatibilityMode(compatibilityMode);
-        def.setPrivileged(isPrivileged(baseKey));
         if (compatibilityMode) {
           Loggers.get(getClass()).debug("API compatibility mode is enabled on plugin {} [{}] " +
             "(built with API lower than {})",
@@ -116,10 +107,6 @@ public class PluginLoader {
     return classloadersByBasePlugin.values();
   }
 
-  private static boolean isPrivileged(String basePluginKey) {
-    return PRIVILEGED_PLUGINS_BASE_KEYS.contains(basePluginKey);
-  }
-
   /**
    * Instantiates collection of {@link org.sonar.api.Plugin} according to given metadata and classloaders
    *
index 58e3d6fd5d551c2ac405a36ce4e6c184db71a885..432296e40fcb452d7a387c2a3704b042321039d1 100644 (file)
@@ -147,15 +147,6 @@ public class PluginLoaderTest {
     // TODO test mask - require change in sonar-classloader
   }
 
-  @Test
-  public void plugin_is_recognised_as_privileged_if_key_is_views_and_extends_no_other_plugins() throws IOException {
-    PluginInfo governance = createPluginInfo("governance");
-
-    Collection<PluginClassLoaderDef> defs = loader.defineClassloaders(ImmutableMap.of("governance", governance));
-
-    assertThat(defs.iterator().next().isPrivileged()).isTrue();
-  }
-
   @Test
   public void plugin_is_not_recognised_as_system_extension_if_key_is_governance_and_extends_another_plugin() throws IOException {
     PluginInfo foo = createPluginInfo("foo");
index 6aab3e55223881cf75efc264a174421921407337..97a4e8053d6c6601c2ebf97dfd16d87160d82cce 100644 (file)
@@ -52,7 +52,7 @@ public class FakeBillingPlugin implements Plugin {
 
   private static boolean isRunningInSQ() {
     try {
-      Class.forName("org.sonar.plugin.PrivilegedPluginBridge");
+      Class.forName("org.sonar.server.plugins.privileged.CoreExtensionBridge");
       return true;
     } catch (ClassNotFoundException e) {
       return false;
index b656d46f524df9ea7ac26d5c0aa20eb5e07f5abd..df27964476ebc7809925a438c19aaaf5c005a154 100644 (file)
@@ -62,7 +62,7 @@ public class FakeGovernancePlugin implements Plugin {
 
   private static boolean isRunningInSQ() {
     try {
-      Class.forName("org.sonar.plugin.PrivilegedPluginBridge");
+      Class.forName("org.sonar.server.plugins.privileged.CoreExtensionBridge");
       return true;
     } catch (ClassNotFoundException e) {
       return false;