]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7510 add sonar-plugin-bridge and ReportAnalysisComponentProvider
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 29 Mar 2016 16:10:21 +0000 (18:10 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 31 Mar 2016 09:34:41 +0000 (11:34 +0200)
new sonar-plugin-bridge maven module replaces modules sonar-dev-cockpit-bridge and sonar-governance-bridge
ReportAnalysisComponentProvider generalizes loading component in the Compute Engine task processing analysis report which was specifically in Dev Cockpit before, as a method of DevCockpitBridge

44 files changed:
pom.xml
server/pom.xml
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
server/sonar-dev-cockpit-bridge/pom.xml [deleted file]
server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/DevCockpitBridge.java [deleted file]
server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/PersistDevelopersDelegate.java [deleted file]
server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/package-info.java [deleted file]
server/sonar-governance-bridge/pom.xml [deleted file]
server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/GovernanceBridge.java [deleted file]
server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/package-info.java [deleted file]
server/sonar-plugin-bridge/pom.xml [new file with mode: 0644]
server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/PrivilegedPluginBridge.java [new file with mode: 0644]
server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/ReportAnalysisComponentProvider.java [new file with mode: 0644]
server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/package-info.java [new file with mode: 0644]
server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/package-info.java [new file with mode: 0644]
server/sonar-server/pom.xml
server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactory.java
server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactoryImpl.java
server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java
server/sonar-server/src/main/java/org/sonar/server/computation/developer/PersistDevelopersDelegate.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/developer/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDevelopersStep.java
server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java
server/sonar-server/src/main/java/org/sonar/server/computation/taskprocessor/report/ReportTaskProcessor.java
server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrap.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitStopper.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/package-info.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceBootstrap.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceStopper.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/governance/bridge/package-info.java [deleted file]
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 [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopper.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/package-info.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulatorTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDevelopersStepTest.java
server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrapTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitStopperTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceBootstrapTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceStopperTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraperTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopperTest.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java

diff --git a/pom.xml b/pom.xml
index ded0eaa437e4d2062bd50cbbb87943a1056891ff..1733d94735f61c7b7a04a0a88fb0e2c343820be3 100644 (file)
--- a/pom.xml
+++ b/pom.xml
       </dependency>
       <dependency>
         <groupId>org.sonarsource.sonarqube</groupId>
-        <artifactId>sonar-dev-cockpit-bridge</artifactId>
-        <version>${project.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.sonarsource.sonarqube</groupId>
-        <artifactId>sonar-governance-bridge</artifactId>
+        <artifactId>sonar-plugin-bridge</artifactId>
         <version>${project.version}</version>
       </dependency>
       <dependency>
index 5f7aab7d92b4e47f245efc3a0f4aee4888ddaf35..0802fb2eb61ab57d3cd7b327dd81436104fa3fd8 100644 (file)
@@ -16,8 +16,7 @@
     <module>sonar-search</module>
     <module>sonar-server</module>
     <module>sonar-ce</module>
-    <module>sonar-dev-cockpit-bridge</module>
-    <module>sonar-governance-bridge</module>
+    <module>sonar-plugin-bridge</module>
     <module>sonar-web</module>
     <module>sonar-server-benchmarks</module>
   </modules>
index 168b1b2dae11ad306c32e92e9a779d5f7e65a47e..bd2d9e11eb0daee1e06800d11d8c8ef92044de23 100644 (file)
@@ -75,11 +75,7 @@ import org.sonar.server.computation.queue.PurgeCeActivities;
 import org.sonar.server.computation.taskprocessor.CeTaskProcessorModule;
 import org.sonar.server.debt.DebtModelPluginRepository;
 import org.sonar.server.debt.DebtRulesXMLImporter;
-import org.sonar.server.devcockpit.bridge.DevCockpitBootstrap;
-import org.sonar.server.devcockpit.bridge.DevCockpitStopper;
 import org.sonar.server.event.NewAlerts;
-import org.sonar.server.governance.bridge.GovernanceBootstrap;
-import org.sonar.server.governance.bridge.GovernanceStopper;
 import org.sonar.server.issue.IssueUpdater;
 import org.sonar.server.issue.index.IssueAuthorizationIndexer;
 import org.sonar.server.issue.index.IssueIndex;
@@ -112,6 +108,8 @@ import org.sonar.server.platform.TempFolderProvider;
 import org.sonar.server.platform.monitoring.JmxConnectionFactoryProvider;
 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.properties.ProjectSettingsFactory;
 import org.sonar.server.qualityprofile.BuiltInProfiles;
 import org.sonar.server.qualityprofile.QProfileComparison;
@@ -548,13 +546,9 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
     // ViewsBootstrap.class, Views not supported in 5.5
     // ViewsStopper.class, Views not supported in 5.5
 
-    // Developer Cockpit plugin
-    DevCockpitBootstrap.class,
-    DevCockpitStopper.class,
-
-    // Governance plugin
-    GovernanceBootstrap.class,
-    GovernanceStopper.class,
+    // privileged plugins
+    PrivilegedPluginsBootstraper.class,
+    PrivilegedPluginsStopper.class,
 
     // Compute engine (must be after Views and Developer Cockpit)
     CeModule.class,
index d767f42a1bbc420e64e49dae14878a6b73ae8a14..15abf853225a58d11a09eb3f997e49a3ef032671 100644 (file)
@@ -79,7 +79,7 @@ public class ComputeEngineContainerImplTest {
     assertThat(picoContainer.getComponentAdapters())
       .hasSize(
         CONTAINER_ITSELF
-          + 78 // level 4
+          + 76 // level 4
           + 5 // content of CeModule
           + 7 // content of CeQueueModule
           + 4 // content of ReportProcessingModule
diff --git a/server/sonar-dev-cockpit-bridge/pom.xml b/server/sonar-dev-cockpit-bridge/pom.xml
deleted file mode 100644 (file)
index 87f2e82..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.sonarsource.sonarqube</groupId>
-    <artifactId>server</artifactId>
-    <version>5.5-SNAPSHOT</version>
-    <relativePath>..</relativePath>
-  </parent>
-  <artifactId>sonar-dev-cockpit-bridge</artifactId>
-  <name>SonarQube :: Developer Cockpit Bridge</name>
-
-  <dependencies>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sonar-plugin-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sonar-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>com.google.code.findbugs</groupId>
-      <artifactId>jsr305</artifactId>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <skipTests>${skipServerTests}</skipTests>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
-</project>
diff --git a/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/DevCockpitBridge.java b/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/DevCockpitBridge.java
deleted file mode 100644 (file)
index 55bbdf8..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.devcockpit;
-
-import java.util.List;
-import org.sonar.core.platform.ComponentContainer;
-
-/**
- * Interface implemented by the Extension point exposed by the Developer Cockpit plugin that serves as the unique access
- * point from the whole SQ instance into the Developer Cockpit plugin.
- */
-public interface DevCockpitBridge {
-
-  /**
-   * Bootstraps the Developer Cockpit plugin.
-   *
-   * @param parent the parent ComponentContainer which provides Platform components for Developer Cockpit to use.
-   *
-   * @throws IllegalStateException if called more than once
-   */
-  void startDevCockpit(ComponentContainer parent);
-
-  /**
-   * This method is called when Platform is shutting down.
-   */
-  void stopDevCockpit();
-
-  /**
-   * Return the list of components to add to the state-full container of a Compute Engine report analysis task
-   */
-  List<Object> getCeComponents();
-
-}
diff --git a/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/PersistDevelopersDelegate.java b/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/PersistDevelopersDelegate.java
deleted file mode 100644 (file)
index 927bb9a..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.devcockpit;
-
-/**
- * This interface is used to delegate the persistence of developers to the Developer Cockpit plugin
- */
-public interface PersistDevelopersDelegate {
-
-  void execute();
-
-}
diff --git a/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/package-info.java b/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/package-info.java
deleted file mode 100644 (file)
index fbf52f1..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.devcockpit;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-governance-bridge/pom.xml b/server/sonar-governance-bridge/pom.xml
deleted file mode 100644 (file)
index 3c49da1..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.sonarsource.sonarqube</groupId>
-    <artifactId>server</artifactId>
-    <version>5.5-SNAPSHOT</version>
-    <relativePath>..</relativePath>
-  </parent>
-  <artifactId>sonar-governance-bridge</artifactId>
-  <name>SonarQube :: Governance Bridge</name>
-
-  <dependencies>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sonar-plugin-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sonar-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>com.google.code.findbugs</groupId>
-      <artifactId>jsr305</artifactId>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <skipTests>${skipServerTests}</skipTests>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
-</project>
diff --git a/server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/GovernanceBridge.java b/server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/GovernanceBridge.java
deleted file mode 100644 (file)
index 03c3e63..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.governance;
-
-import org.sonar.core.platform.ComponentContainer;
-
-/**
- * Interface implemented by the Extension point exposed by the Governance plugin that serves as the unique access point from
- * the whole SQ instance into the Governance plugin.
- */
-public interface GovernanceBridge {
-
-  /**
-   * Bootstraps the Governance plugin.
-   *
-   * @param parent the parent ComponentContainer which provides Platform components for Governance to use.
-   *
-   * @throws IllegalStateException if called more than once
-   */
-  void startGovernance(ComponentContainer parent);
-
-  /**
-   * This method is called when Platform is shutting down.
-   */
-  void stopGovernance();
-
-}
diff --git a/server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/package-info.java b/server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/package-info.java
deleted file mode 100644 (file)
index 17c8c94..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.governance;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-plugin-bridge/pom.xml b/server/sonar-plugin-bridge/pom.xml
new file mode 100644 (file)
index 0000000..5c23d7a
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.sonarsource.sonarqube</groupId>
+    <artifactId>server</artifactId>
+    <version>5.5-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+  <artifactId>sonar-plugin-bridge</artifactId>
+  <name>SonarQube :: Priviledged Plugin Bridge</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>sonar-plugin-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>sonar-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.google.code.findbugs</groupId>
+      <artifactId>jsr305</artifactId>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <skipTests>${skipServerTests}</skipTests>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
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
new file mode 100644 (file)
index 0000000..b8cb97b
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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-plugin-bridge/src/main/java/org/sonar/plugin/ce/ReportAnalysisComponentProvider.java b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/ReportAnalysisComponentProvider.java
new file mode 100644 (file)
index 0000000..e477236
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.ce;
+
+import java.util.List;
+import org.sonar.api.ce.ComputeEngineSide;
+
+@ComputeEngineSide
+public interface ReportAnalysisComponentProvider {
+
+  /**
+   * Return the list of components to add to the state-full container of a Compute Engine report analysis task
+   */
+  List<Object> getComponents();
+
+}
diff --git a/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/package-info.java b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/package-info.java
new file mode 100644 (file)
index 0000000..0eda913
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.plugin.ce;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/package-info.java b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/package-info.java
new file mode 100644 (file)
index 0000000..66b29c5
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.plugin;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index 36880dd10cde1f668b740a1bc120b3874dc80799..2b1a4860dbbd5a5a78cb571253c7703f788d8d50 100644 (file)
     </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>sonar-dev-cockpit-bridge</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sonar-governance-bridge</artifactId>
+      <artifactId>sonar-plugin-bridge</artifactId>
     </dependency>
 
     <!-- unit tests -->
index 8893ab2c885d3467ff043f698424fdb9441bc40b..fe1b292278a8db0e11077da073a3c430e96a15c3 100644 (file)
 package org.sonar.server.computation.container;
 
 import javax.annotation.Nullable;
-import org.sonar.core.platform.ComponentContainer;
 import org.sonar.ce.queue.CeTask;
-import org.sonar.server.devcockpit.DevCockpitBridge;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
 
 public interface ContainerFactory {
 
-  ComputeEngineContainer create(ComponentContainer parent, CeTask task, @Nullable DevCockpitBridge devCockpitBridge);
+  ComputeEngineContainer create(ComponentContainer parent, CeTask task, @Nullable ReportAnalysisComponentProvider[] componentProviders);
 }
index 78d2f863f01169f0233e9e762cd97d1991f6dd77..eaba445cf16c2cc086bbf7f7393233565485be91 100644 (file)
 package org.sonar.server.computation.container;
 
 import javax.annotation.Nullable;
-import org.sonar.core.platform.ComponentContainer;
 import org.sonar.ce.queue.CeTask;
-import org.sonar.server.devcockpit.DevCockpitBridge;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
 
 public class ContainerFactoryImpl implements ContainerFactory {
   @Override
-  public ComputeEngineContainer create(ComponentContainer parent, CeTask task, @Nullable DevCockpitBridge devCockpitBridge) {
-    return new ComputeEngineContainerImpl(parent, new ReportComputeEngineContainerPopulator(task, devCockpitBridge));
+  public ComputeEngineContainer create(ComponentContainer parent, CeTask task, @Nullable ReportAnalysisComponentProvider[] componentProviders) {
+    return new ComputeEngineContainerImpl(parent, new ReportComputeEngineContainerPopulator(task, componentProviders));
   }
 }
index 1c79df7d1cbde90da4460d900844e8e0a128013b..c0c9797d73614fd381e0cca8b148113dd8bfae45 100644 (file)
@@ -25,6 +25,7 @@ import javax.annotation.Nullable;
 import org.sonar.ce.queue.CeTask;
 import org.sonar.core.issue.tracking.Tracker;
 import org.sonar.core.platform.ContainerPopulator;
+import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
 import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl;
 import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl;
 import org.sonar.server.computation.batch.BatchReportReaderImpl;
@@ -90,16 +91,15 @@ import org.sonar.server.computation.step.ComputationStepExecutor;
 import org.sonar.server.computation.step.ComputationSteps;
 import org.sonar.server.computation.step.ReportComputationSteps;
 import org.sonar.server.computation.taskprocessor.MutableTaskResultHolderImpl;
-import org.sonar.server.devcockpit.DevCockpitBridge;
 import org.sonar.server.view.index.ViewIndex;
 
 public final class ReportComputeEngineContainerPopulator implements ContainerPopulator<ComputeEngineContainer> {
   private final CeTask task;
-  private final DevCockpitBridge devCockpitBridge;
+  private final ReportAnalysisComponentProvider[] componentProviders;
 
-  public ReportComputeEngineContainerPopulator(CeTask task, @Nullable DevCockpitBridge devCockpitBridge) {
+  public ReportComputeEngineContainerPopulator(CeTask task, @Nullable ReportAnalysisComponentProvider[] componentProviders) {
     this.task = task;
-    this.devCockpitBridge = devCockpitBridge;
+    this.componentProviders = componentProviders == null ? new ReportAnalysisComponentProvider[0] : componentProviders;
   }
 
   @Override
@@ -108,8 +108,8 @@ public final class ReportComputeEngineContainerPopulator implements ContainerPop
     container.add(task);
     container.add(steps);
     container.addSingletons(componentClasses());
-    if (devCockpitBridge != null) {
-      container.addSingletons(devCockpitBridge.getCeComponents());
+    for (ReportAnalysisComponentProvider componentProvider : componentProviders) {
+      container.addSingletons(componentProvider.getComponents());
     }
     container.addSingletons(steps.orderedStepClasses());
   }
@@ -207,8 +207,7 @@ public final class ReportComputeEngineContainerPopulator implements ContainerPop
       // views
       ViewIndex.class,
 
-      MeasureToMeasureDto.class
-      );
+      MeasureToMeasureDto.class);
   }
 
 }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/developer/PersistDevelopersDelegate.java b/server/sonar-server/src/main/java/org/sonar/server/computation/developer/PersistDevelopersDelegate.java
new file mode 100644 (file)
index 0000000..f8f6055
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.computation.developer;
+
+/**
+ * This interface is used to delegate the persistence of developers to the Developer Cockpit plugin
+ */
+public interface PersistDevelopersDelegate {
+
+  void execute();
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/developer/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/computation/developer/package-info.java
new file mode 100644 (file)
index 0000000..3ddfcdf
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.computation.developer;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index eb2da0e91581bfe4046dd7431ceb3f37ad8991c3..24ee34ab3a91420c2a89b473c2a4d8207196e38f 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.server.computation.step;
 
-import org.sonar.server.devcockpit.PersistDevelopersDelegate;
+import org.sonar.server.computation.developer.PersistDevelopersDelegate;
 
 /**
  * Persist developers, should only be execute when the Dev Cockpit plugin is installed.
index 8343cc318ca6035734ff2061d442ebb5d205c8f6..5300cf398b5cefa8c4d1746fbaa7cb4c24257743 100644 (file)
@@ -24,7 +24,7 @@ import java.util.Arrays;
 import java.util.List;
 import javax.annotation.Nonnull;
 import org.sonar.server.computation.container.ComputeEngineContainer;
-import org.sonar.server.devcockpit.DevCockpitBridge;
+import org.sonar.server.computation.developer.PersistDevelopersDelegate;
 
 import static com.google.common.collect.FluentIterable.from;
 
@@ -33,6 +33,8 @@ import static com.google.common.collect.FluentIterable.from;
  */
 public class ReportComputationSteps extends AbstractComputationSteps {
 
+  private static final String DEVELOPER_COCKPIT_PLUGIN_NAME = "Developer Cockpit";
+
   private static final List<Class<? extends ComputationStep>> STEPS = Arrays.asList(
     ExtractReportStep.class,
     LogScannerContextStep.class,
@@ -127,7 +129,7 @@ public class ReportComputationSteps extends AbstractComputationSteps {
 
   private class AllowPersistDevelopersStepIfDevCockpitPluginInstalled implements Predicate<Class<? extends ComputationStep>> {
 
-    private final boolean devCockpitIsInstalled = computeEngineContainer.getComponentByType(DevCockpitBridge.class) != null;
+    private final boolean devCockpitIsInstalled = computeEngineContainer.getComponentByType(PersistDevelopersDelegate.class) != null;
 
     @Override
     public boolean apply(@Nonnull Class<? extends ComputationStep> input) {
index 912177763db54a84ed93413c49f4813445d0b0f7..0a24deab12ad42dc2f7c9adb08b3e5ea5435a853 100644 (file)
@@ -28,11 +28,11 @@ import org.sonar.ce.settings.ThreadLocalSettings;
 import org.sonar.ce.taskprocessor.CeTaskProcessor;
 import org.sonar.core.platform.ComponentContainer;
 import org.sonar.db.ce.CeTaskTypes;
+import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
 import org.sonar.server.computation.container.ComputeEngineContainer;
 import org.sonar.server.computation.container.ContainerFactory;
 import org.sonar.server.computation.step.ComputationStepExecutor;
 import org.sonar.server.computation.taskprocessor.TaskResultHolder;
-import org.sonar.server.devcockpit.DevCockpitBridge;
 
 public class ReportTaskProcessor implements CeTaskProcessor {
 
@@ -41,24 +41,24 @@ public class ReportTaskProcessor implements CeTaskProcessor {
   private final ContainerFactory containerFactory;
   private final ComponentContainer serverContainer;
   @CheckForNull
-  private final DevCockpitBridge devCockpitBridge;
+  private final ReportAnalysisComponentProvider[] componentProviders;
 
   /**
-   * Used when Developer Cockpit plugin is installed
+   * Used when at least one Privileged plugin is installed
    */
-  public ReportTaskProcessor(ContainerFactory containerFactory, ComponentContainer serverContainer, DevCockpitBridge devCockpitBridge) {
+  public ReportTaskProcessor(ContainerFactory containerFactory, ComponentContainer serverContainer, ReportAnalysisComponentProvider[] componentProviders) {
     this.containerFactory = containerFactory;
     this.serverContainer = serverContainer;
-    this.devCockpitBridge = devCockpitBridge;
+    this.componentProviders = componentProviders;
   }
 
   /**
-   * Used when Developer Cockpit plugin is not installed
+   * Used when no privileged plugin is installed
    */
   public ReportTaskProcessor(ContainerFactory containerFactory, ComponentContainer serverContainer) {
     this.containerFactory = containerFactory;
     this.serverContainer = serverContainer;
-    this.devCockpitBridge = null;
+    this.componentProviders = null;
   }
 
   @Override
@@ -68,7 +68,7 @@ public class ReportTaskProcessor implements CeTaskProcessor {
 
   @Override
   public CeTaskResult process(CeTask task) {
-    ComputeEngineContainer ceContainer = containerFactory.create(serverContainer, task, devCockpitBridge);
+    ComputeEngineContainer ceContainer = containerFactory.create(serverContainer, task, componentProviders);
     ThreadLocalSettings ceSettings = null;
     try {
       ceSettings = ceContainer.getComponentByType(ThreadLocalSettings.class);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrap.java b/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrap.java
deleted file mode 100644 (file)
index 5924c43..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.devcockpit.bridge;
-
-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.server.devcockpit.DevCockpitBridge;
-
-/**
- * Startup task to responsible to bootstrap the Developer Cockpit plugin when it is installed.
- */
-public class DevCockpitBootstrap implements ServerStartHandler {
-  private static final Logger LOGGER = Loggers.get(DevCockpitBootstrap.class);
-
-  private final ComponentContainer componentContainer;
-
-  public DevCockpitBootstrap(ComponentContainer componentContainer) {
-    this.componentContainer = componentContainer;
-  }
-
-  @Override
-  public void onServerStart(Server server) {
-    DevCockpitBridge bridge = componentContainer.getComponentByType(DevCockpitBridge.class);
-    if (bridge != null) {
-      Profiler profiler = Profiler.create(LOGGER).startInfo("Bootstrapping Developer Cockpit");
-      bridge.startDevCockpit(componentContainer);
-      profiler.stopInfo();
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitStopper.java b/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitStopper.java
deleted file mode 100644 (file)
index dc5ffb8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.devcockpit.bridge;
-
-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.server.devcockpit.DevCockpitBridge;
-
-/**
- * As an component of PlatformLevel4, this class is responsible for notifying shutdown to the Developer Cockpit plugin when its
- * installed.
- */
-public class DevCockpitStopper implements Startable {
-  private static final Logger LOGGER = Loggers.get(DevCockpitStopper.class);
-
-  private final ComponentContainer platformContainer;
-
-  public DevCockpitStopper(ComponentContainer platformContainer) {
-    this.platformContainer = platformContainer;
-  }
-
-  @Override
-  public void start() {
-    // nothing to do, Views plugins is started by DevCockpitBootstrap
-  }
-
-  @Override
-  public void stop() {
-    DevCockpitBridge devCockpitBridge = platformContainer.getComponentByType(DevCockpitBridge.class);
-    if (devCockpitBridge != null) {
-      Profiler profiler = Profiler.create(LOGGER).startInfo("Stopping Developer Cockpit");
-      devCockpitBridge.stopDevCockpit();
-      profiler.stopInfo();
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/package-info.java
deleted file mode 100644 (file)
index 1401c99..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.devcockpit.bridge;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceBootstrap.java b/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceBootstrap.java
deleted file mode 100644 (file)
index 273f40e..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.governance.bridge;
-
-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.server.governance.GovernanceBridge;
-
-/**
- * Startup task to responsible to bootstrap the Governance plugin when it is installed.
- */
-public class GovernanceBootstrap implements ServerStartHandler {
-  private static final Logger LOGGER = Loggers.get(GovernanceBootstrap.class);
-
-  private final ComponentContainer componentContainer;
-
-  public GovernanceBootstrap(ComponentContainer componentContainer) {
-    this.componentContainer = componentContainer;
-  }
-
-  @Override
-  public void onServerStart(Server server) {
-    GovernanceBridge governanceBridge = componentContainer.getComponentByType(GovernanceBridge.class);
-    if (governanceBridge != null) {
-      Profiler profiler = Profiler.create(LOGGER).startInfo("Bootstrapping Governance plugin");
-      governanceBridge.startGovernance(componentContainer);
-      profiler.stopInfo();
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceStopper.java b/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceStopper.java
deleted file mode 100644 (file)
index 6ecb566..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.governance.bridge;
-
-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.server.governance.GovernanceBridge;
-
-/**
- * As an component of PlatformLevel4, this class is responsible for notifying shutdown to the Governance plugin when its
- * installed.
- */
-public class GovernanceStopper implements Startable {
-  private static final Logger LOGGER = Loggers.get(GovernanceStopper.class);
-
-  private final ComponentContainer platformContainer;
-
-  public GovernanceStopper(ComponentContainer platformContainer) {
-    this.platformContainer = platformContainer;
-  }
-
-  @Override
-  public void start() {
-    // nothing to do, Governance plugins is started by GovernanceBootstrap
-  }
-
-  @Override
-  public void stop() {
-    GovernanceBridge viewsBridge = platformContainer.getComponentByType(GovernanceBridge.class);
-    if (viewsBridge != null) {
-      Profiler profiler = Profiler.create(LOGGER).startInfo("Stopping Governance plugin");
-      viewsBridge.stopGovernance();
-      profiler.stopInfo();
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/package-info.java
deleted file mode 100644 (file)
index 5ad47aa..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.governance.bridge;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
index e832c4b4d8a3fa34e29bbc9092a0105b98d43e8b..10913fa94ca695e5e625e6067c9d56c118e0c648 100644 (file)
@@ -89,16 +89,12 @@ import org.sonar.server.debt.DebtModelPluginRepository;
 import org.sonar.server.debt.DebtModelService;
 import org.sonar.server.debt.DebtModelXMLExporter;
 import org.sonar.server.debt.DebtRulesXMLImporter;
-import org.sonar.server.devcockpit.bridge.DevCockpitBootstrap;
-import org.sonar.server.devcockpit.bridge.DevCockpitStopper;
 import org.sonar.server.duplication.ws.DuplicationsJsonWriter;
 import org.sonar.server.duplication.ws.DuplicationsParser;
 import org.sonar.server.duplication.ws.DuplicationsWs;
 import org.sonar.server.es.IndexCreator;
 import org.sonar.server.es.IndexDefinitions;
 import org.sonar.server.event.NewAlerts;
-import org.sonar.server.governance.bridge.GovernanceBootstrap;
-import org.sonar.server.governance.bridge.GovernanceStopper;
 import org.sonar.server.issue.ActionService;
 import org.sonar.server.issue.AddTagsAction;
 import org.sonar.server.issue.AssignAction;
@@ -180,6 +176,8 @@ import org.sonar.server.plugins.PluginDownloader;
 import org.sonar.server.plugins.ServerExtensionInstaller;
 import org.sonar.server.plugins.UpdateCenterClient;
 import org.sonar.server.plugins.UpdateCenterMatrixFactory;
+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.InstallAction;
@@ -674,13 +672,9 @@ public class PlatformLevel4 extends PlatformLevel {
       CancelAllAction.class,
       PluginsWs.class,
 
-      // Developer Cockpit plugin
-      DevCockpitBootstrap.class,
-      DevCockpitStopper.class,
-
-      // Governance plugin
-      GovernanceBootstrap.class,
-      GovernanceStopper.class,
+      // privileged plugins
+      PrivilegedPluginsBootstraper.class,
+      PrivilegedPluginsStopper.class,
 
       // Compute engine (must be after Views and Developer Cockpit)
       CeModule.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
new file mode 100644 (file)
index 0000000..e433e9d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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
new file mode 100644 (file)
index 0000000..c9c7177
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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
new file mode 100644 (file)
index 0000000..992ccb1
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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;
+
index 0674fd77fee3a5875b32c53fce743607b7ec1274..7254400aff3369ac338d06346cf5cabcd3d5990d 100644 (file)
@@ -21,19 +21,20 @@ package org.sonar.server.computation.container;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.junit.Test;
-import org.sonar.core.platform.ComponentContainer;
 import org.sonar.ce.queue.CeTask;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
 import org.sonar.server.computation.step.ComputationStep;
 import org.sonar.server.computation.step.PersistComponentsStep;
 import org.sonar.server.computation.step.PersistDevelopersStep;
-import org.sonar.server.devcockpit.DevCockpitBridge;
-import org.sonar.server.devcockpit.PersistDevelopersDelegate;
 
 import static com.google.common.base.Predicates.notNull;
 import static com.google.common.collect.FluentIterable.from;
@@ -100,29 +101,22 @@ public class ReportComputeEngineContainerPopulatorTest {
   }
 
   @Test
-  public void PersistDevelopersStep_is_added_to_the_container_when_DevCockpitBridge_exist() {
-    DevCockpitBridge devCockpitBridge = mock(DevCockpitBridge.class);
-    when(devCockpitBridge.getCeComponents()).thenReturn(Arrays.<Object>asList(PersistDevelopersDelegateImpl.class));
+  public void Components_of_ReportAnalysisComponentProvider_are_added_to_the_container() {
+    Object object = new Object();
+    Class<MyClass> clazz = MyClass.class;
+    ReportAnalysisComponentProvider componentProvider = mock(ReportAnalysisComponentProvider.class);
+    when(componentProvider.getComponents()).thenReturn(ImmutableList.of(object, clazz));
 
-    underTest = new ReportComputeEngineContainerPopulator(task, devCockpitBridge);
+    underTest = new ReportComputeEngineContainerPopulator(task, new ReportAnalysisComponentProvider[]{componentProvider});
     AddedObjectsRecorderComputeEngineContainer container = new AddedObjectsRecorderComputeEngineContainer();
-    container.add(devCockpitBridge);
+    container.add(componentProvider);
     underTest.populateContainer(container);
 
-    assertThat(container.added).contains(PersistDevelopersStep.class);
+    assertThat(container.added).contains(object, clazz);
   }
 
-  @Test
-  public void components_from_DevCockpitBridge_are_added_to_the_container_when_DevCockpitBridge_exist() {
-    DevCockpitBridge devCockpitBridge = mock(DevCockpitBridge.class);
-    when(devCockpitBridge.getCeComponents()).thenReturn(Arrays.<Object>asList(PersistDevelopersDelegateImpl.class));
-
-    underTest = new ReportComputeEngineContainerPopulator(task, devCockpitBridge);
-    AddedObjectsRecorderComputeEngineContainer container = new AddedObjectsRecorderComputeEngineContainer();
-    container.add(devCockpitBridge);
-    underTest.populateContainer(container);
+  private static final class MyClass {
 
-    assertThat(container.added).contains(PersistDevelopersDelegateImpl.class);
   }
 
   private enum IsComputationStep implements Predicate<Class<?>> {
@@ -170,12 +164,23 @@ public class ReportComputeEngineContainerPopulatorTest {
       }
       return null;
     }
-  }
 
-  private static class PersistDevelopersDelegateImpl implements PersistDevelopersDelegate {
     @Override
-    public void execute() {
-      // nothing to do
+    public <T> List<T> getComponentsByType(final Class<T> type) {
+      return from(added)
+        .filter(new Predicate<Object>() {
+          @Override
+          public boolean apply(@Nonnull Object input) {
+            return input.getClass().getSimpleName().contains(type.getSimpleName());
+          }
+        }).transform(new Function<Object, T>() {
+          @Override
+          @Nonnull
+          public T apply(@Nonnull Object input) {
+            return (T) input;
+          }
+        }).toList();
     }
   }
+
 }
index 33bdf73b63904125984cf9e5fb7970a46ba63762..9ef1e5b8d54f3f1a36739cbd12c976250af15fa6 100644 (file)
@@ -20,7 +20,7 @@
 package org.sonar.server.computation.step;
 
 import org.junit.Test;
-import org.sonar.server.devcockpit.PersistDevelopersDelegate;
+import org.sonar.server.computation.developer.PersistDevelopersDelegate;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrapTest.java b/server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrapTest.java
deleted file mode 100644 (file)
index 3a9f9b9..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.devcockpit.bridge;
-
-import org.junit.Test;
-import org.sonar.api.platform.Server;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.devcockpit.DevCockpitBridge;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class DevCockpitBootstrapTest {
-  private ComponentContainer componentContainer = new ComponentContainer();
-  private DevCockpitBridge devCockpitBridge = mock(DevCockpitBridge.class);
-
-  private DevCockpitBootstrap underTest = new DevCockpitBootstrap(componentContainer);
-
-  @Test
-  public void onServerStart_calls_startDevCockpit_if_DevCockpitBridge_exists_in_container() {
-    componentContainer.add(devCockpitBridge);
-    componentContainer.startComponents();
-
-    underTest.onServerStart(mock(Server.class));
-
-    verify(devCockpitBridge).startDevCockpit(componentContainer);
-    verifyNoMoreInteractions(devCockpitBridge);
-  }
-
-  @Test
-  public void onServerStart_does_not_call_startDevCockpit_if_DevCockpitBridge_does_not_exist_in_container() {
-    underTest.onServerStart(mock(Server.class));
-
-    verifyNoMoreInteractions(devCockpitBridge);
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitStopperTest.java b/server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitStopperTest.java
deleted file mode 100644 (file)
index 7e8c5a8..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.devcockpit.bridge;
-
-import org.junit.Test;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.devcockpit.DevCockpitBridge;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class DevCockpitStopperTest {
-  private ComponentContainer componentContainer = new ComponentContainer();
-  private DevCockpitBridge devCockpitBridge = mock(DevCockpitBridge.class);
-
-  private DevCockpitStopper underTest = new DevCockpitStopper(componentContainer);
-
-  @Test
-  public void stop_calls_stopDevCockpit_if_DevCockpitBridge_exists_in_container() {
-    componentContainer.add(devCockpitBridge);
-    componentContainer.startComponents();
-
-    underTest.stop();
-
-
-    verify(devCockpitBridge).stopDevCockpit();
-    verifyNoMoreInteractions(devCockpitBridge);
-  }
-
-  @Test
-  public void stop_does_not_call_stopDevCockpit_if_DevCockpitBridge_does_not_exist_in_container() {
-    underTest.stop();
-
-    verifyNoMoreInteractions(devCockpitBridge);
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceBootstrapTest.java b/server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceBootstrapTest.java
deleted file mode 100644 (file)
index b34bc9b..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.governance.bridge;
-
-import org.junit.Test;
-import org.sonar.api.platform.Server;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.governance.GovernanceBridge;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class GovernanceBootstrapTest {
-  private Server server = mock(Server.class);
-  private ComponentContainer componentContainer = spy(new ComponentContainer());
-  private GovernanceBootstrap underTest = new GovernanceBootstrap(componentContainer);
-
-  @Test
-  public void onServerStart_has_no_effect_when_ComponentContainer_contains_no_GovernanceBridge() {
-    underTest.onServerStart(server);
-
-    verify(componentContainer).getComponentByType(GovernanceBridge.class);
-    verifyNoMoreInteractions(componentContainer);
-  }
-
-  @Test
-  public void onServerStart_calls_GovernanceBridge_startGovernance_when_present_in_ComponentContainer() {
-    GovernanceBridge governanceBridge = mock(GovernanceBridge.class);
-    componentContainer.add(governanceBridge);
-
-    underTest.onServerStart(server);
-
-    verify(governanceBridge).startGovernance(componentContainer);
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceStopperTest.java b/server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceStopperTest.java
deleted file mode 100644 (file)
index 46cf92e..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.governance.bridge;
-
-import org.junit.Test;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.governance.GovernanceBridge;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class GovernanceStopperTest {
-  private ComponentContainer componentContainer = spy(new ComponentContainer());
-  private GovernanceStopper underTest = new GovernanceStopper(componentContainer);
-
-  @Test
-  public void start_has_no_effect() {
-    underTest.start();
-    
-    verifyNoMoreInteractions(componentContainer);
-  }
-
-  @Test
-  public void stop_has_no_effect_when_no_GovernanceBridge() {
-    underTest.stop();
-
-    verify(componentContainer).getComponentByType(GovernanceBridge.class);
-    verifyNoMoreInteractions(componentContainer);
-  }
-
-  @Test
-  public void stop_calls_GovernanceBridge_stopGovernance_when_in_ComponentContainer() {
-    GovernanceBridge governanceBridge = mock(GovernanceBridge.class);
-
-    componentContainer.add(governanceBridge);
-
-    underTest.stop();
-
-    verify(governanceBridge).stopGovernance();
-  }
-}
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
new file mode 100644 (file)
index 0000000..722189d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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
new file mode 100644 (file)
index 0000000..88a130e
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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 c7b12d46971e3ca4b78bb4f5cc06ffe7dfa31398..b63adfaace2e7e81bb04ad3c3f54b8f97e26cb72 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.core.platform;
 
+import java.util.List;
+
 public interface ContainerPopulator<T extends ContainerPopulator.Container> {
   void populateContainer(T container);
 
@@ -28,5 +30,7 @@ public interface ContainerPopulator<T extends ContainerPopulator.Container> {
     Container addSingletons(Iterable<?> components);
 
     <T> T getComponentByType(Class<T> type);
+
+    <T> List<T> getComponentsByType(Class<T> type);
   }
 }