2 * SonarQube, open source software quality management tool.
3 * Copyright (C) 2008-2014 SonarSource
4 * mailto:contact AT sonarsource DOT com
6 * SonarQube 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 * SonarQube 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 org.sonar.core.issue.tracking.Tracker;
25 import org.sonar.core.platform.ContainerPopulator;
26 import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl;
27 import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl;
28 import org.sonar.server.computation.batch.BatchReportReaderImpl;
29 import org.sonar.server.computation.component.DbIdsRepositoryImpl;
30 import org.sonar.server.computation.component.ReportTreeRootHolderImpl;
31 import org.sonar.server.computation.component.SettingsRepositoryImpl;
32 import org.sonar.server.computation.debt.DebtModelHolderImpl;
33 import org.sonar.server.computation.event.EventRepositoryImpl;
34 import org.sonar.server.computation.filesystem.ComputationTempFolderProvider;
35 import org.sonar.server.computation.issue.BaseIssuesLoader;
36 import org.sonar.server.computation.issue.CloseIssuesOnRemovedComponentsVisitor;
37 import org.sonar.server.computation.issue.ComponentIssuesRepositoryImpl;
38 import org.sonar.server.computation.issue.ComponentsWithUnprocessedIssues;
39 import org.sonar.server.computation.issue.DebtAggregator;
40 import org.sonar.server.computation.issue.DebtCalculator;
41 import org.sonar.server.computation.issue.DefaultAssignee;
42 import org.sonar.server.computation.issue.IntegrateIssuesVisitor;
43 import org.sonar.server.computation.issue.IssueAssigner;
44 import org.sonar.server.computation.issue.IssueCache;
45 import org.sonar.server.computation.issue.IssueCounter;
46 import org.sonar.server.computation.issue.IssueLifecycle;
47 import org.sonar.server.computation.issue.IssueVisitors;
48 import org.sonar.server.computation.issue.LoadComponentUuidsHavingOpenIssuesVisitor;
49 import org.sonar.server.computation.issue.NewDebtAggregator;
50 import org.sonar.server.computation.issue.NewDebtCalculator;
51 import org.sonar.server.computation.issue.RuleRepositoryImpl;
52 import org.sonar.server.computation.issue.RuleTagsCopier;
53 import org.sonar.server.computation.issue.ScmAccountToUser;
54 import org.sonar.server.computation.issue.ScmAccountToUserLoader;
55 import org.sonar.server.computation.issue.TrackerBaseInputFactory;
56 import org.sonar.server.computation.issue.TrackerExecution;
57 import org.sonar.server.computation.issue.TrackerRawInputFactory;
58 import org.sonar.server.computation.issue.UpdateConflictResolver;
59 import org.sonar.server.computation.issue.commonrule.BranchCoverageRule;
60 import org.sonar.server.computation.issue.commonrule.CommentDensityRule;
61 import org.sonar.server.computation.issue.commonrule.CommonRuleEngineImpl;
62 import org.sonar.server.computation.issue.commonrule.DuplicatedBlockRule;
63 import org.sonar.server.computation.issue.commonrule.LineCoverageRule;
64 import org.sonar.server.computation.issue.commonrule.SkippedTestRule;
65 import org.sonar.server.computation.issue.commonrule.TestErrorRule;
66 import org.sonar.server.computation.language.LanguageRepositoryImpl;
67 import org.sonar.server.computation.measure.MeasureComputersHolderImpl;
68 import org.sonar.server.computation.measure.MeasureComputersVisitor;
69 import org.sonar.server.computation.measure.MeasureRepositoryImpl;
70 import org.sonar.server.computation.metric.MetricModule;
71 import org.sonar.server.computation.period.PeriodsHolderImpl;
72 import org.sonar.server.computation.qualitygate.EvaluationResultTextConverterImpl;
73 import org.sonar.server.computation.qualitygate.QualityGateHolderImpl;
74 import org.sonar.server.computation.qualitygate.QualityGateServiceImpl;
75 import org.sonar.server.computation.qualityprofile.ActiveRulesHolderImpl;
76 import org.sonar.server.computation.queue.CeTask;
77 import org.sonar.server.computation.scm.ScmInfoRepositoryImpl;
78 import org.sonar.server.computation.source.LastCommitVisitor;
79 import org.sonar.server.computation.source.SourceHashRepositoryImpl;
80 import org.sonar.server.computation.source.SourceLinesRepositoryImpl;
81 import org.sonar.server.computation.sqale.SqaleMeasuresVisitor;
82 import org.sonar.server.computation.sqale.SqaleNewMeasuresVisitor;
83 import org.sonar.server.computation.sqale.SqaleRatingSettings;
84 import org.sonar.server.computation.step.ComputationStepExecutor;
85 import org.sonar.server.computation.step.ComputationSteps;
86 import org.sonar.server.computation.step.ReportComputationSteps;
87 import org.sonar.server.view.index.ViewIndex;
89 public final class ReportComputeEngineContainerPopulator implements ContainerPopulator<ComputeEngineContainer> {
90 private final CeTask task;
92 public ReportComputeEngineContainerPopulator(CeTask task) {
97 public void populateContainer(ComputeEngineContainer container) {
98 ComputationSteps steps = new ReportComputationSteps(container);
100 container.add(steps);
101 container.addSingletons(componentClasses());
102 container.addSingletons(steps.orderedStepClasses());
106 * List of all objects to be injected in the picocontainer dedicated to computation stack.
107 * Does not contain the steps declared in {@link ReportComputationSteps#orderedStepClasses()}.
109 private static List componentClasses() {
110 return Arrays.asList(
111 ComputationStepExecutor.class,
112 new ComputationTempFolderProvider(),
117 AnalysisMetadataHolderImpl.class,
118 BatchReportDirectoryHolderImpl.class,
119 ReportTreeRootHolderImpl.class,
120 PeriodsHolderImpl.class,
121 QualityGateHolderImpl.class,
122 DebtModelHolderImpl.class,
123 SqaleRatingSettings.class,
124 ActiveRulesHolderImpl.class,
125 MeasureComputersHolderImpl.class,
127 BatchReportReaderImpl.class,
130 LanguageRepositoryImpl.class,
131 MeasureRepositoryImpl.class,
132 EventRepositoryImpl.class,
133 SettingsRepositoryImpl.class,
134 DbIdsRepositoryImpl.class,
135 QualityGateServiceImpl.class,
136 EvaluationResultTextConverterImpl.class,
137 SourceLinesRepositoryImpl.class,
138 SourceHashRepositoryImpl.class,
139 ScmInfoRepositoryImpl.class,
142 RuleRepositoryImpl.class,
143 ScmAccountToUserLoader.class,
144 ScmAccountToUser.class,
146 DefaultAssignee.class,
148 IssueLifecycle.class,
149 ComponentsWithUnprocessedIssues.class,
150 ComponentIssuesRepositoryImpl.class,
153 CommonRuleEngineImpl.class,
154 BranchCoverageRule.class,
155 LineCoverageRule.class,
156 CommentDensityRule.class,
157 DuplicatedBlockRule.class,
159 SkippedTestRule.class,
161 // order is important: DebtAggregator then NewDebtAggregator (new debt requires debt)
162 DebtCalculator.class,
163 DebtAggregator.class,
164 NewDebtCalculator.class,
165 NewDebtAggregator.class,
167 RuleTagsCopier.class,
170 // visitors : order is important, measure computers must be executed at the end in order to access to every measures / issues
171 LoadComponentUuidsHavingOpenIssuesVisitor.class,
172 IntegrateIssuesVisitor.class,
173 CloseIssuesOnRemovedComponentsVisitor.class,
174 SqaleMeasuresVisitor.class,
175 SqaleNewMeasuresVisitor.class,
176 LastCommitVisitor.class,
177 MeasureComputersVisitor.class,
179 UpdateConflictResolver.class,
180 TrackerBaseInputFactory.class,
181 TrackerRawInputFactory.class,
183 TrackerExecution.class,
184 BaseIssuesLoader.class,