3 * Copyright (C) 2009-2016 SonarSource SA
4 * mailto:contact AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.computation.taskprocessor.report;
22 import java.util.Collections;
24 import javax.annotation.CheckForNull;
25 import org.sonar.core.platform.ComponentContainer;
26 import org.sonar.db.ce.CeTaskTypes;
27 import org.sonar.server.computation.container.ComputeEngineContainer;
28 import org.sonar.server.computation.container.ContainerFactory;
29 import org.sonar.server.computation.queue.CeTask;
30 import org.sonar.server.computation.queue.CeTaskResult;
31 import org.sonar.server.computation.step.ComputationStepExecutor;
32 import org.sonar.server.computation.taskprocessor.CeTaskProcessor;
33 import org.sonar.server.computation.taskprocessor.TaskResultHolder;
34 import org.sonar.server.devcockpit.DevCockpitBridge;
36 public class ReportTaskProcessor implements CeTaskProcessor {
38 private static final Set<String> HANDLED_TYPES = Collections.singleton(CeTaskTypes.REPORT);
40 private final ContainerFactory containerFactory;
41 private final ComponentContainer serverContainer;
43 private final DevCockpitBridge devCockpitBridge;
46 * Used when Developer Cockpit plugin is installed
48 public ReportTaskProcessor(ContainerFactory containerFactory, ComponentContainer serverContainer, DevCockpitBridge devCockpitBridge) {
49 this.containerFactory = containerFactory;
50 this.serverContainer = serverContainer;
51 this.devCockpitBridge = devCockpitBridge;
55 * Used when Developer Cockpit plugin is not installed
57 public ReportTaskProcessor(ContainerFactory containerFactory, ComponentContainer serverContainer) {
58 this.containerFactory = containerFactory;
59 this.serverContainer = serverContainer;
60 this.devCockpitBridge = null;
64 public Set<String> getHandledCeTaskTypes() {
69 public CeTaskResult process(CeTask task) {
70 ComputeEngineContainer ceContainer = containerFactory.create(serverContainer, task, devCockpitBridge);
72 ceContainer.getComponentByType(ComputationStepExecutor.class).execute();
73 return ceContainer.getComponentByType(TaskResultHolder.class).getResult();
75 ceContainer.cleanup();