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.container;
22 import java.util.Arrays;
23 import java.util.List;
24 import javax.annotation.Nullable;
25 import org.sonar.ce.queue.CeTask;
26 import org.sonar.ce.settings.SettingsLoader;
27 import org.sonar.core.issue.tracking.Tracker;
28 import org.sonar.core.platform.ContainerPopulator;
29 import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
30 import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl;
31 import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl;
32 import org.sonar.server.computation.batch.BatchReportReaderImpl;
33 import org.sonar.server.computation.component.DbIdsRepositoryImpl;
34 import org.sonar.server.computation.component.SettingsRepositoryImpl;
35 import org.sonar.server.computation.component.TreeRootHolderImpl;
36 import org.sonar.server.computation.duplication.CrossProjectDuplicationStatusHolderImpl;
37 import org.sonar.server.computation.duplication.DuplicationRepositoryImpl;
38 import org.sonar.server.computation.duplication.IntegrateCrossProjectDuplications;
39 import org.sonar.server.computation.event.EventRepositoryImpl;
40 import org.sonar.server.computation.filemove.FileSimilarityImpl;
41 import org.sonar.server.computation.filemove.MutableMovedFilesRepositoryImpl;
42 import org.sonar.server.computation.filemove.SourceSimilarityImpl;
43 import org.sonar.server.computation.filesystem.ComputationTempFolderProvider;
44 import org.sonar.server.computation.issue.BaseIssuesLoader;
45 import org.sonar.server.computation.issue.CloseIssuesOnRemovedComponentsVisitor;
46 import org.sonar.server.computation.issue.ComponentIssuesRepositoryImpl;
47 import org.sonar.server.computation.issue.ComponentsWithUnprocessedIssues;
48 import org.sonar.server.computation.issue.DebtCalculator;
49 import org.sonar.server.computation.issue.DefaultAssignee;
50 import org.sonar.server.computation.issue.EffortAggregator;
51 import org.sonar.server.computation.issue.IntegrateIssuesVisitor;
52 import org.sonar.server.computation.issue.IssueAssigner;
53 import org.sonar.server.computation.issue.IssueCache;
54 import org.sonar.server.computation.issue.IssueCounter;
55 import org.sonar.server.computation.issue.IssueLifecycle;
56 import org.sonar.server.computation.issue.IssueVisitors;
57 import org.sonar.server.computation.issue.LoadComponentUuidsHavingOpenIssuesVisitor;
58 import org.sonar.server.computation.issue.MovedIssueVisitor;
59 import org.sonar.server.computation.issue.NewEffortAggregator;
60 import org.sonar.server.computation.issue.NewEffortCalculator;
61 import org.sonar.server.computation.issue.RuleRepositoryImpl;
62 import org.sonar.server.computation.issue.RuleTagsCopier;
63 import org.sonar.server.computation.issue.RuleTypeCopier;
64 import org.sonar.server.computation.issue.ScmAccountToUser;
65 import org.sonar.server.computation.issue.ScmAccountToUserLoader;
66 import org.sonar.server.computation.issue.TrackerBaseInputFactory;
67 import org.sonar.server.computation.issue.TrackerExecution;
68 import org.sonar.server.computation.issue.TrackerRawInputFactory;
69 import org.sonar.server.computation.issue.UpdateConflictResolver;
70 import org.sonar.server.computation.issue.commonrule.BranchCoverageRule;
71 import org.sonar.server.computation.issue.commonrule.CommentDensityRule;
72 import org.sonar.server.computation.issue.commonrule.CommonRuleEngineImpl;
73 import org.sonar.server.computation.issue.commonrule.DuplicatedBlockRule;
74 import org.sonar.server.computation.issue.commonrule.LineCoverageRule;
75 import org.sonar.server.computation.issue.commonrule.SkippedTestRule;
76 import org.sonar.server.computation.issue.commonrule.TestErrorRule;
77 import org.sonar.server.computation.issue.filter.IssueFilter;
78 import org.sonar.server.computation.language.LanguageRepositoryImpl;
79 import org.sonar.server.computation.measure.MeasureComputersHolderImpl;
80 import org.sonar.server.computation.measure.MeasureComputersVisitor;
81 import org.sonar.server.computation.measure.MeasureRepositoryImpl;
82 import org.sonar.server.computation.measure.MeasureToMeasureDto;
83 import org.sonar.server.computation.metric.MetricModule;
84 import org.sonar.server.computation.period.PeriodsHolderImpl;
85 import org.sonar.server.computation.posttask.PostProjectAnalysisTasksExecutor;
86 import org.sonar.server.computation.qualitygate.EvaluationResultTextConverterImpl;
87 import org.sonar.server.computation.qualitygate.QualityGateHolderImpl;
88 import org.sonar.server.computation.qualitygate.QualityGateServiceImpl;
89 import org.sonar.server.computation.qualitygate.QualityGateStatusHolderImpl;
90 import org.sonar.server.computation.qualitymodel.NewQualityModelMeasuresVisitor;
91 import org.sonar.server.computation.qualitymodel.QualityModelMeasuresVisitor;
92 import org.sonar.server.computation.qualitymodel.RatingSettings;
93 import org.sonar.server.computation.qualityprofile.ActiveRulesHolderImpl;
94 import org.sonar.server.computation.scm.ScmInfoRepositoryImpl;
95 import org.sonar.server.computation.source.LastCommitVisitor;
96 import org.sonar.server.computation.source.SourceHashRepositoryImpl;
97 import org.sonar.server.computation.source.SourceLinesRepositoryImpl;
98 import org.sonar.server.computation.step.ComputationStepExecutor;
99 import org.sonar.server.computation.step.ComputationSteps;
100 import org.sonar.server.computation.step.ReportComputationSteps;
101 import org.sonar.server.computation.taskprocessor.MutableTaskResultHolderImpl;
102 import org.sonar.server.view.index.ViewIndex;
104 public final class ReportComputeEngineContainerPopulator implements ContainerPopulator<ComputeEngineContainer> {
105 private static final ReportAnalysisComponentProvider[] NO_REPORT_ANALYSIS_COMPONENT_PROVIDERS = new ReportAnalysisComponentProvider[0];
107 private final CeTask task;
108 private final ReportAnalysisComponentProvider[] componentProviders;
110 public ReportComputeEngineContainerPopulator(CeTask task, @Nullable ReportAnalysisComponentProvider[] componentProviders) {
112 this.componentProviders = componentProviders == null ? NO_REPORT_ANALYSIS_COMPONENT_PROVIDERS : componentProviders;
116 public void populateContainer(ComputeEngineContainer container) {
117 ComputationSteps steps = new ReportComputationSteps(container);
118 container.add(SettingsLoader.class);
120 container.add(steps);
121 container.addSingletons(componentClasses());
122 for (ReportAnalysisComponentProvider componentProvider : componentProviders) {
123 container.addSingletons(componentProvider.getComponents());
125 container.addSingletons(steps.orderedStepClasses());
129 * List of all objects to be injected in the picocontainer dedicated to computation stack.
130 * Does not contain the steps declared in {@link ReportComputationSteps#orderedStepClasses()}.
132 private static List componentClasses() {
133 return Arrays.asList(
134 PostProjectAnalysisTasksExecutor.class,
135 ComputationStepExecutor.class,
138 new ComputationTempFolderProvider(),
143 AnalysisMetadataHolderImpl.class,
144 CrossProjectDuplicationStatusHolderImpl.class,
145 BatchReportDirectoryHolderImpl.class,
146 TreeRootHolderImpl.class,
147 PeriodsHolderImpl.class,
148 QualityGateHolderImpl.class,
149 QualityGateStatusHolderImpl.class,
150 RatingSettings.class,
151 ActiveRulesHolderImpl.class,
152 MeasureComputersHolderImpl.class,
153 MutableTaskResultHolderImpl.class,
155 BatchReportReaderImpl.class,
158 LanguageRepositoryImpl.class,
159 MeasureRepositoryImpl.class,
160 EventRepositoryImpl.class,
161 SettingsRepositoryImpl.class,
162 DbIdsRepositoryImpl.class,
163 QualityGateServiceImpl.class,
164 EvaluationResultTextConverterImpl.class,
165 SourceLinesRepositoryImpl.class,
166 SourceHashRepositoryImpl.class,
167 ScmInfoRepositoryImpl.class,
168 DuplicationRepositoryImpl.class,
171 RuleRepositoryImpl.class,
172 ScmAccountToUserLoader.class,
173 ScmAccountToUser.class,
175 DefaultAssignee.class,
177 IssueLifecycle.class,
178 ComponentsWithUnprocessedIssues.class,
179 ComponentIssuesRepositoryImpl.class,
183 CommonRuleEngineImpl.class,
184 BranchCoverageRule.class,
185 LineCoverageRule.class,
186 CommentDensityRule.class,
187 DuplicatedBlockRule.class,
189 SkippedTestRule.class,
191 // order is important: RuleTypeCopier must be the first one. And DebtAggregator must be before NewDebtAggregator (new debt requires
193 RuleTypeCopier.class,
194 RuleTagsCopier.class,
195 DebtCalculator.class,
196 EffortAggregator.class,
197 NewEffortCalculator.class,
198 NewEffortAggregator.class,
201 MovedIssueVisitor.class,
203 // visitors : order is important, measure computers must be executed at the end in order to access to every measures / issues
204 LoadComponentUuidsHavingOpenIssuesVisitor.class,
205 IntegrateIssuesVisitor.class,
206 CloseIssuesOnRemovedComponentsVisitor.class,
207 QualityModelMeasuresVisitor.class,
208 NewQualityModelMeasuresVisitor.class,
209 LastCommitVisitor.class,
210 MeasureComputersVisitor.class,
212 UpdateConflictResolver.class,
213 TrackerBaseInputFactory.class,
214 TrackerRawInputFactory.class,
216 TrackerExecution.class,
217 BaseIssuesLoader.class,
220 SourceSimilarityImpl.class,
221 FileSimilarityImpl.class,
222 MutableMovedFilesRepositoryImpl.class,
225 IntegrateCrossProjectDuplications.class,
230 MeasureToMeasureDto.class);