3 * Copyright (C) 2009-2022 SonarSource SA
4 * mailto:info 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.ce.task.projectanalysis.taskprocessor;
22 import java.util.Collections;
24 import javax.annotation.CheckForNull;
25 import org.sonar.ce.task.CeTask;
26 import org.sonar.ce.task.CeTaskResult;
27 import org.sonar.ce.task.container.TaskContainer;
28 import org.sonar.ce.task.projectanalysis.container.ContainerFactory;
29 import org.sonar.ce.task.step.ComputationStepExecutor;
30 import org.sonar.ce.task.taskprocessor.CeTaskProcessor;
31 import org.sonar.ce.task.taskprocessor.TaskResultHolder;
32 import org.sonar.core.platform.ComponentContainer;
33 import org.sonar.db.ce.CeTaskTypes;
34 import org.sonar.ce.task.projectanalysis.container.ReportAnalysisComponentProvider;
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 ReportAnalysisComponentProvider[] componentProviders;
46 * Used when at least one Privileged plugin is installed
48 public ReportTaskProcessor(ContainerFactory containerFactory, ComponentContainer serverContainer, ReportAnalysisComponentProvider[] componentProviders) {
49 this.containerFactory = containerFactory;
50 this.serverContainer = serverContainer;
51 this.componentProviders = componentProviders;
55 * Used when no privileged plugin is installed
57 public ReportTaskProcessor(ContainerFactory containerFactory, ComponentContainer serverContainer) {
58 this.containerFactory = containerFactory;
59 this.serverContainer = serverContainer;
60 this.componentProviders = null;
64 * Used when loaded in WebServer where none of the dependencies are available and where only
65 * {@link #getHandledCeTaskTypes()} will be called.
67 public ReportTaskProcessor() {
68 this(null, null, null);
72 public Set<String> getHandledCeTaskTypes() {
77 public CeTaskResult process(CeTask task) {
78 try (TaskContainer ceContainer = containerFactory.create(serverContainer, task, componentProviders)) {
81 ceContainer.getComponentByType(ComputationStepExecutor.class).execute();
82 return ceContainer.getComponentByType(TaskResultHolder.class).getResult();