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
</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>
<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>
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;
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;
// 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,
assertThat(picoContainer.getComponentAdapters())
.hasSize(
CONTAINER_ITSELF
- + 78 // level 4
+ + 76 // level 4
+ 5 // content of CeModule
+ 7 // content of CeQueueModule
+ 4 // content of ReportProcessingModule
+++ /dev/null
-<?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>
+++ /dev/null
-/*
- * 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();
-
-}
+++ /dev/null
-/*
- * 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();
-
-}
+++ /dev/null
-/*
- * 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;
+++ /dev/null
-<?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>
+++ /dev/null
-/*
- * 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();
-
-}
+++ /dev/null
-/*
- * 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;
--- /dev/null
+<?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>
--- /dev/null
+/*
+ * 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();
+
+}
--- /dev/null
+/*
+ * 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();
+
+}
--- /dev/null
+/*
+ * 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;
--- /dev/null
+/*
+ * 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;
</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 -->
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);
}
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));
}
}
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;
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
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());
}
// views
ViewIndex.class,
- MeasureToMeasureDto.class
- );
+ MeasureToMeasureDto.class);
}
}
--- /dev/null
+/*
+ * 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();
+
+}
--- /dev/null
+/*
+ * 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;
*/
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.
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;
*/
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,
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) {
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 {
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
@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);
+++ /dev/null
-/*
- * 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();
- }
- }
-
-}
+++ /dev/null
-/*
- * 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();
- }
- }
-}
+++ /dev/null
-/*
- * 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;
-
+++ /dev/null
-/*
- * 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();
- }
- }
-
-}
+++ /dev/null
-/*
- * 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();
- }
- }
-}
+++ /dev/null
-/*
- * 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;
-
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;
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;
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,
--- /dev/null
+/*
+ * 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();
+ }
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+ }
+}
--- /dev/null
+/*
+ * 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;
+
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;
}
@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<?>> {
}
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();
}
}
+
}
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;
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
*/
package org.sonar.core.platform;
+import java.util.List;
+
public interface ContainerPopulator<T extends ContainerPopulator.Container> {
void populateContainer(T container);
Container addSingletons(Iterable<?> components);
<T> T getComponentByType(Class<T> type);
+
+ <T> List<T> getComponentsByType(Class<T> type);
}
}