]> source.dussan.org Git - sonarqube.git/commitdiff
bootstrap and stop Governance plugin in SQ 787/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 22 Feb 2016 15:25:34 +0000 (16:25 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 24 Feb 2016 14:54:04 +0000 (15:54 +0100)
server/sonar-server/pom.xml
server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceBootstrap.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceStopper.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/governance/bridge/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java

index 07da679c1d09c36093e77e707fb991ebae222647..fc885aecea72a3f8bb4e6870f19b35cb0affdb1c 100644 (file)
       <groupId>${project.groupId}</groupId>
       <artifactId>sonar-dev-cockpit-bridge</artifactId>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>sonar-governance-bridge</artifactId>
+    </dependency>
 
     <!-- unit tests -->
     <dependency>
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
new file mode 100644 (file)
index 0000000..273f40e
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.governance.bridge;
+
+import org.sonar.api.platform.Server;
+import org.sonar.api.platform.ServerStartHandler;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.api.utils.log.Profiler;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.server.governance.GovernanceBridge;
+
+/**
+ * Startup task to responsible to bootstrap the Governance plugin when it is installed.
+ */
+public class GovernanceBootstrap implements ServerStartHandler {
+  private static final Logger LOGGER = Loggers.get(GovernanceBootstrap.class);
+
+  private final ComponentContainer componentContainer;
+
+  public GovernanceBootstrap(ComponentContainer componentContainer) {
+    this.componentContainer = componentContainer;
+  }
+
+  @Override
+  public void onServerStart(Server server) {
+    GovernanceBridge governanceBridge = componentContainer.getComponentByType(GovernanceBridge.class);
+    if (governanceBridge != null) {
+      Profiler profiler = Profiler.create(LOGGER).startInfo("Bootstrapping Governance plugin");
+      governanceBridge.startGovernance(componentContainer);
+      profiler.stopInfo();
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceStopper.java b/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/GovernanceStopper.java
new file mode 100644 (file)
index 0000000..6ecb566
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.governance.bridge;
+
+import org.picocontainer.Startable;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.api.utils.log.Profiler;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.server.governance.GovernanceBridge;
+
+/**
+ * As an component of PlatformLevel4, this class is responsible for notifying shutdown to the Governance plugin when its
+ * installed.
+ */
+public class GovernanceStopper implements Startable {
+  private static final Logger LOGGER = Loggers.get(GovernanceStopper.class);
+
+  private final ComponentContainer platformContainer;
+
+  public GovernanceStopper(ComponentContainer platformContainer) {
+    this.platformContainer = platformContainer;
+  }
+
+  @Override
+  public void start() {
+    // nothing to do, Governance plugins is started by GovernanceBootstrap
+  }
+
+  @Override
+  public void stop() {
+    GovernanceBridge viewsBridge = platformContainer.getComponentByType(GovernanceBridge.class);
+    if (viewsBridge != null) {
+      Profiler profiler = Profiler.create(LOGGER).startInfo("Stopping Governance plugin");
+      viewsBridge.stopGovernance();
+      profiler.stopInfo();
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/governance/bridge/package-info.java
new file mode 100644 (file)
index 0000000..5ad47aa
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.governance.bridge;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index 66132486453a581db587df88d18713c43bbb3ba6..02fb6cd3345e790fd7ee86f5a22f930a44fa1e69 100644 (file)
@@ -107,6 +107,8 @@ 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;
@@ -699,6 +701,10 @@ public class PlatformLevel4 extends PlatformLevel {
       DevCockpitBootstrap.class,
       DevCockpitStopper.class,
 
+      // Governance plugin
+      GovernanceBootstrap.class,
+      GovernanceStopper.class,
+
       // Compute engine (must be after Views and Developer Cockpit)
       CeModule.class,
       CeQueueModule.class,