<artifactId>sonar-views-bridge</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-dev-cockpit-bridge</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>sonar-java-plugin</artifactId>
<module>sonar-process</module>
<module>sonar-process-monitor</module>
<module>sonar-search</module>
- <module>sonar-views-bridge</module>
<module>sonar-server</module>
+ <module>sonar-views-bridge</module>
+ <module>sonar-dev-cockpit-bridge</module>
<module>sonar-web</module>
<module>sonar-server-benchmarks</module>
</modules>
--- /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.3-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>
+
+ <profiles>
+ <profile>
+ <id>release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+</project>
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.devcockpit;
+
+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();
+
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.server.devcockpit;
+
+import javax.annotation.ParametersAreNonnullByDefault;
<groupId>${project.groupId}</groupId>
<artifactId>sonar-views-bridge</artifactId>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sonar-dev-cockpit-bridge</artifactId>
+ </dependency>
<!-- unit tests -->
<dependency>
<groupId>${project.groupId}</groupId>
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.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, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.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, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.server.devcockpit.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.view.index.ViewIndex;
import org.sonar.server.view.index.ViewIndexDefinition;
import org.sonar.server.view.index.ViewIndexer;
-import org.sonar.server.ws.WebServicesWs;
import org.sonar.server.ws.WebServiceEngine;
+import org.sonar.server.ws.WebServicesWs;
import org.sonar.server.ws.WsResponseCommonFormat;
public class PlatformLevel4 extends PlatformLevel {
ViewsBootstrap.class,
ViewsStopper.class,
+ // Developer Cockpit plugin
+ DevCockpitBootstrap.class,
+ DevCockpitStopper.class,
+
// UI
GlobalNavigationAction.class,
SettingsNavigationAction.class,
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.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, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.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);
+ }
+}