aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-03-29 18:10:21 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-03-31 11:34:41 +0200
commit9b88ac1448e5f8dc359a928602ed2883515611c5 (patch)
tree4e4a8ad4efd4fd25ad7aac0b0893799ae1837370
parentcee47fb86197710892e9d23cbdc35813f51845f7 (diff)
downloadsonarqube-9b88ac1448e5f8dc359a928602ed2883515611c5.tar.gz
sonarqube-9b88ac1448e5f8dc359a928602ed2883515611c5.zip
SONAR-7510 add sonar-plugin-bridge and ReportAnalysisComponentProvider
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
-rw-r--r--pom.xml7
-rw-r--r--server/pom.xml3
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java16
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java2
-rw-r--r--server/sonar-dev-cockpit-bridge/pom.xml41
-rw-r--r--server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/DevCockpitBridge.java50
-rw-r--r--server/sonar-plugin-bridge/pom.xml (renamed from server/sonar-governance-bridge/pom.xml)4
-rw-r--r--server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/PrivilegedPluginBridge.java (renamed from server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/GovernanceBridge.java)18
-rw-r--r--server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/ReportAnalysisComponentProvider.java33
-rw-r--r--server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/package-info.java (renamed from server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/package-info.java)2
-rw-r--r--server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/package-info.java (renamed from server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/package-info.java)2
-rw-r--r--server/sonar-server/pom.xml6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactory.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactoryImpl.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java15
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/developer/PersistDevelopersDelegate.java (renamed from server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/PersistDevelopersDelegate.java)2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/developer/package-info.java (renamed from server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/package-info.java)3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDevelopersStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/taskprocessor/report/ReportTaskProcessor.java16
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitStopper.java56
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceBootstrap.java52
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java16
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraper.java (renamed from server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrap.java)23
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopper.java (renamed from server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceStopper.java)27
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/package-info.java (renamed from server/sonar-server/src/main/java/org/sonar/server/governance/bridge/package-info.java)2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulatorTest.java51
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDevelopersStepTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceBootstrapTest.java54
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceStopperTest.java60
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraperTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrapTest.java)23
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopperTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitStopperTest.java)24
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java4
33 files changed, 176 insertions, 460 deletions
diff --git a/pom.xml b/pom.xml
index ded0eaa437e..1733d94735f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -520,12 +520,7 @@
</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>
diff --git a/server/pom.xml b/server/pom.xml
index 5f7aab7d92b..0802fb2eb61 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -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>
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
index 168b1b2dae1..bd2d9e11eb0 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
@@ -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,
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
index d767f42a1bb..15abf853225 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
@@ -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
index 87f2e8276e8..00000000000
--- a/server/sonar-dev-cockpit-bridge/pom.xml
+++ /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
index 55bbdf85d92..00000000000
--- a/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/DevCockpitBridge.java
+++ /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-governance-bridge/pom.xml b/server/sonar-plugin-bridge/pom.xml
index 3c49da1690e..5c23d7a334e 100644
--- a/server/sonar-governance-bridge/pom.xml
+++ b/server/sonar-plugin-bridge/pom.xml
@@ -7,8 +7,8 @@
<version>5.5-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
- <artifactId>sonar-governance-bridge</artifactId>
- <name>SonarQube :: Governance Bridge</name>
+ <artifactId>sonar-plugin-bridge</artifactId>
+ <name>SonarQube :: Priviledged Plugin Bridge</name>
<dependencies>
<dependency>
diff --git a/server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/GovernanceBridge.java b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/PrivilegedPluginBridge.java
index 03c3e633383..b8cb97babac 100644
--- a/server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/GovernanceBridge.java
+++ b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/PrivilegedPluginBridge.java
@@ -17,28 +17,30 @@
* 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;
+package org.sonar.plugin;
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.
+ * 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 GovernanceBridge {
+public interface PrivilegedPluginBridge {
+
+ String getPluginName();
/**
- * Bootstraps the Governance plugin.
+ * Bootstraps the plugin.
*
- * @param parent the parent ComponentContainer which provides Platform components for Governance to use.
+ * @param parent the parent ComponentContainer which provides Platform components for the Privileged plugin to use.
*
* @throws IllegalStateException if called more than once
*/
- void startGovernance(ComponentContainer parent);
+ void startPlugin(ComponentContainer parent);
/**
* This method is called when Platform is shutting down.
*/
- void stopGovernance();
+ 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
index 00000000000..e47723602d3
--- /dev/null
+++ b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/ReportAnalysisComponentProvider.java
@@ -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-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/package-info.java b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/package-info.java
index fbf52f1b14e..0eda9134660 100644
--- a/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/package-info.java
+++ b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/ce/package-info.java
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@ParametersAreNonnullByDefault
-package org.sonar.server.devcockpit;
+package org.sonar.plugin.ce;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/package-info.java b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/package-info.java
index 17c8c94552d..66b29c54962 100644
--- a/server/sonar-governance-bridge/src/main/java/org/sonar/server/governance/package-info.java
+++ b/server/sonar-plugin-bridge/src/main/java/org/sonar/plugin/package-info.java
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@ParametersAreNonnullByDefault
-package org.sonar.server.governance;
+package org.sonar.plugin;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml
index 36880dd10cd..2b1a4860dbb 100644
--- a/server/sonar-server/pom.xml
+++ b/server/sonar-server/pom.xml
@@ -171,11 +171,7 @@
</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 -->
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactory.java b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactory.java
index 8893ab2c885..fe1b292278a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactory.java
@@ -20,11 +20,11 @@
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);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactoryImpl.java
index 78d2f863f01..eaba445cf16 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactoryImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ContainerFactoryImpl.java
@@ -20,13 +20,13 @@
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));
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java
index 1c79df7d1cb..c0c9797d736 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java
@@ -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-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/PersistDevelopersDelegate.java b/server/sonar-server/src/main/java/org/sonar/server/computation/developer/PersistDevelopersDelegate.java
index 927bb9a3d4d..f8f60553365 100644
--- a/server/sonar-dev-cockpit-bridge/src/main/java/org/sonar/server/devcockpit/PersistDevelopersDelegate.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/developer/PersistDevelopersDelegate.java
@@ -17,7 +17,7 @@
* 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;
+package org.sonar.server.computation.developer;
/**
* This interface is used to delegate the persistence of developers to the Developer Cockpit plugin
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/computation/developer/package-info.java
index 1401c9986e5..3ddfcdfcb98 100644
--- 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/computation/developer/package-info.java
@@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@ParametersAreNonnullByDefault
-package org.sonar.server.devcockpit.bridge;
+package org.sonar.server.computation.developer;
import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDevelopersStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDevelopersStep.java
index eb2da0e9158..24ee34ab3a9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDevelopersStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDevelopersStep.java
@@ -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.
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java
index 8343cc318ca..5300cf398b5 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ReportComputationSteps.java
@@ -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) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/taskprocessor/report/ReportTaskProcessor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/taskprocessor/report/ReportTaskProcessor.java
index 912177763db..0a24deab12a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/taskprocessor/report/ReportTaskProcessor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/taskprocessor/report/ReportTaskProcessor.java
@@ -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/DevCockpitStopper.java b/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitStopper.java
deleted file mode 100644
index dc5ffb8d98c..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitStopper.java
+++ /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/governance/bridge/GovernanceBootstrap.java b/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceBootstrap.java
deleted file mode 100644
index 273f40e6e51..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceBootstrap.java
+++ /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/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
index e832c4b4d8a..10913fa94ca 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
@@ -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/devcockpit/bridge/DevCockpitBootstrap.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraper.java
index 5924c430225..e433e9d6a5a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrap.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraper.java
@@ -17,34 +17,37 @@
* 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;
+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.server.devcockpit.DevCockpitBridge;
+import org.sonar.plugin.PrivilegedPluginBridge;
+
+import static java.lang.String.format;
/**
- * Startup task to responsible to bootstrap the Developer Cockpit plugin when it is installed.
+ * Startup task to responsible to bootstrap installed Privileged plugins (if any).
*/
-public class DevCockpitBootstrap implements ServerStartHandler {
- private static final Logger LOGGER = Loggers.get(DevCockpitBootstrap.class);
+public class PrivilegedPluginsBootstraper implements ServerStartHandler {
+ private static final Logger LOGGER = Loggers.get(PrivilegedPluginsBootstraper.class);
private final ComponentContainer componentContainer;
- public DevCockpitBootstrap(ComponentContainer componentContainer) {
+ public PrivilegedPluginsBootstraper(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);
+ 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/governance/bridge/GovernanceStopper.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopper.java
index 6ecb566af6d..c9c71773657 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceStopper.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopper.java
@@ -17,39 +17,42 @@
* 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;
+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.server.governance.GovernanceBridge;
+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 Governance plugin when its
- * installed.
+ * As an component of PlatformLevel4, this class is responsible for notifying shutdown to the installed Privileged plugins
+ * (if any) when its installed.
*/
-public class GovernanceStopper implements Startable {
- private static final Logger LOGGER = Loggers.get(GovernanceStopper.class);
+public class PrivilegedPluginsStopper implements Startable {
+ private static final Logger LOGGER = Loggers.get(PrivilegedPluginsStopper.class);
private final ComponentContainer platformContainer;
- public GovernanceStopper(ComponentContainer platformContainer) {
+ public PrivilegedPluginsStopper(ComponentContainer platformContainer) {
this.platformContainer = platformContainer;
}
@Override
public void start() {
- // nothing to do, Governance plugins is started by GovernanceBootstrap
+ // nothing to do, privileged plugins are started by PrivilegedPluginsBootstraper
}
@Override
public void stop() {
- GovernanceBridge viewsBridge = platformContainer.getComponentByType(GovernanceBridge.class);
- if (viewsBridge != null) {
- Profiler profiler = Profiler.create(LOGGER).startInfo("Stopping Governance plugin");
- viewsBridge.stopGovernance();
+ 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/governance/bridge/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/privileged/package-info.java
index 5ad47aac89a..992ccb1c06e 100644
--- 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/plugins/privileged/package-info.java
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@ParametersAreNonnullByDefault
-package org.sonar.server.governance.bridge;
+package org.sonar.server.plugins.privileged;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulatorTest.java
index 0674fd77fee..7254400aff3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulatorTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulatorTest.java
@@ -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();
}
}
+
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDevelopersStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDevelopersStepTest.java
index 33bdf73b639..9ef1e5b8d54 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDevelopersStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDevelopersStepTest.java
@@ -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/governance/bridge/GovernanceBootstrapTest.java b/server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceBootstrapTest.java
deleted file mode 100644
index b34bc9b913d..00000000000
--- a/server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceBootstrapTest.java
+++ /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
index 46cf92e4158..00000000000
--- a/server/sonar-server/src/test/java/org/sonar/server/governance/bridge/GovernanceStopperTest.java
+++ /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/devcockpit/bridge/DevCockpitBootstrapTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraperTest.java
index 3a9f9b9c3ac..722189d4fb4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitBootstrapTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsBootstraperTest.java
@@ -17,38 +17,39 @@
* 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;
+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.server.devcockpit.DevCockpitBridge;
+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 DevCockpitBootstrapTest {
+public class PrivilegedPluginsBootstraperTest {
private ComponentContainer componentContainer = new ComponentContainer();
- private DevCockpitBridge devCockpitBridge = mock(DevCockpitBridge.class);
+ private PrivilegedPluginBridge bridge = mock(PrivilegedPluginBridge.class);
- private DevCockpitBootstrap underTest = new DevCockpitBootstrap(componentContainer);
+ private PrivilegedPluginsBootstraper underTest = new PrivilegedPluginsBootstraper(componentContainer);
@Test
- public void onServerStart_calls_startDevCockpit_if_DevCockpitBridge_exists_in_container() {
- componentContainer.add(devCockpitBridge);
+ public void onServerStart_calls_startPlugin_if_Bridge_exists_in_container() {
+ componentContainer.add(bridge);
componentContainer.startComponents();
underTest.onServerStart(mock(Server.class));
- verify(devCockpitBridge).startDevCockpit(componentContainer);
- verifyNoMoreInteractions(devCockpitBridge);
+ verify(bridge).getPluginName();
+ verify(bridge).startPlugin(componentContainer);
+ verifyNoMoreInteractions(bridge);
}
@Test
- public void onServerStart_does_not_call_startDevCockpit_if_DevCockpitBridge_does_not_exist_in_container() {
+ public void onServerStart_does_not_call_startPlugin_if_Bridge_does_not_exist_in_container() {
underTest.onServerStart(mock(Server.class));
- verifyNoMoreInteractions(devCockpitBridge);
+ verifyNoMoreInteractions(bridge);
}
}
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/plugins/privileged/PrivilegedPluginsStopperTest.java
index 7e8c5a86306..88a130edcc7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/devcockpit/bridge/DevCockpitStopperTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/plugins/privileged/PrivilegedPluginsStopperTest.java
@@ -17,38 +17,38 @@
* 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;
+package org.sonar.server.plugins.privileged;
import org.junit.Test;
import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.devcockpit.DevCockpitBridge;
+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 DevCockpitStopperTest {
+public class PrivilegedPluginsStopperTest {
private ComponentContainer componentContainer = new ComponentContainer();
- private DevCockpitBridge devCockpitBridge = mock(DevCockpitBridge.class);
+ private PrivilegedPluginBridge bridge = mock(PrivilegedPluginBridge.class);
- private DevCockpitStopper underTest = new DevCockpitStopper(componentContainer);
+ private PrivilegedPluginsStopper underTest = new PrivilegedPluginsStopper(componentContainer);
@Test
- public void stop_calls_stopDevCockpit_if_DevCockpitBridge_exists_in_container() {
- componentContainer.add(devCockpitBridge);
+ public void stop_calls_stopPlugin_if_Bridge_exists_in_container() {
+ componentContainer.add(bridge);
componentContainer.startComponents();
underTest.stop();
-
- verify(devCockpitBridge).stopDevCockpit();
- verifyNoMoreInteractions(devCockpitBridge);
+ verify(bridge).getPluginName();
+ verify(bridge).stopPlugin();
+ verifyNoMoreInteractions(bridge);
}
@Test
- public void stop_does_not_call_stopDevCockpit_if_DevCockpitBridge_does_not_exist_in_container() {
+ public void stop_does_not_call_stopPlugin_if_Bridge_does_not_exist_in_container() {
underTest.stop();
- verifyNoMoreInteractions(devCockpitBridge);
+ verifyNoMoreInteractions(bridge);
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java b/sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java
index c7b12d46971..b63adfaace2 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java
@@ -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);
}
}