diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-02-27 18:25:32 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-02-27 18:25:32 +0100 |
commit | 041dceb1c50d4e1c073e044ab37a610faae2d6a4 (patch) | |
tree | 19fe404d95c095fbd9cc26191ac58b65c143105c /sonar-batch | |
parent | d3cf13a01891639342cfe34d28d01bf3ce183fa1 (diff) | |
download | sonarqube-041dceb1c50d4e1c073e044ab37a610faae2d6a4.tar.gz sonarqube-041dceb1c50d4e1c073e044ab37a610faae2d6a4.zip |
Fix after refactoring for views
Diffstat (limited to 'sonar-batch')
6 files changed, 22 insertions, 31 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java index 80f2c1f48bd..54c8c7b8524 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java @@ -58,6 +58,9 @@ public class BootstrapContainer extends Container { @Override protected void configure() { container.addSingleton(globalProperties); + if (reactor != null) { + container.addSingleton(reactor); + } container.addSingleton(new PropertiesConfiguration()); container.addSingleton(BootstrapSettings.class); container.addSingleton(ServerClient.class); @@ -95,7 +98,7 @@ public class BootstrapContainer extends Container { @Override protected void doStart() { - Container childModule = new TaskBootstrapContainer(taskCommand, reactor); + Container childModule = new TaskBootstrapContainer(taskCommand); try { installChild(childModule); childModule.start(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectLessTaskContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectLessTaskContainer.java index 1df65ec74cb..24c8463fcca 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectLessTaskContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectLessTaskContainer.java @@ -22,13 +22,13 @@ package org.sonar.batch.bootstrap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.api.batch.bootstrap.ProjectReactor; import org.sonar.api.config.EmailSettings; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.task.Task; import org.sonar.api.task.TaskDefinition; import org.sonar.api.utils.SonarException; import org.sonar.batch.DefaultResourceCreationLock; +import org.sonar.batch.ProjectConfigurator; import org.sonar.batch.components.PastMeasuresLoader; import org.sonar.batch.components.PastSnapshotFinder; import org.sonar.batch.components.PastSnapshotFinderByDate; @@ -62,8 +62,6 @@ import org.sonar.jpa.dao.MeasuresDao; import org.sonar.jpa.session.DefaultDatabaseConnector; import org.sonar.jpa.session.JpaDatabaseSession; -import javax.annotation.Nullable; - /** * Level-3 components. Task-level components that don't depends on project. */ @@ -73,11 +71,11 @@ public class ProjectLessTaskContainer extends Container { private TaskDefinition taskDefinition; - private ProjectReactor reactor; + private boolean projectPresent; - public ProjectLessTaskContainer(TaskDefinition task, @Nullable ProjectReactor reactor) { + public ProjectLessTaskContainer(TaskDefinition task, boolean projectPresent) { this.taskDefinition = task; - this.reactor = reactor; + this.projectPresent = projectPresent; } @Override @@ -86,6 +84,11 @@ public class ProjectLessTaskContainer extends Container { registerDatabaseComponents(); registerCoreProjectLessTasks(); registerProjectLessTaskExtensions(); + if (projectPresent && ExtensionUtils.requiresProject(taskDefinition.getTask())) { + container.addSingleton(ProjectExclusions.class); + container.addSingleton(ProjectReactorReady.class); + container.addSingleton(DryRunDatabase.class); + } } private void registerCoreComponents() { @@ -119,7 +122,7 @@ public class ProjectLessTaskContainer extends Container { container.addSingleton(DefaultResourcePersister.class); container.addSingleton(SourcePersister.class); container.addSingleton(DefaultNotificationManager.class); - + container.addSingleton(ProjectConfigurator.class); } private void registerDatabaseComponents() { @@ -156,13 +159,12 @@ public class ProjectLessTaskContainer extends Container { */ @Override protected void doStart() { - boolean projectPresent = (reactor != null); if (ExtensionUtils.requiresProject(taskDefinition.getTask())) { if (!projectPresent) { throw new SonarException("Task '" + taskDefinition.getName() + "' requires to be run on a project"); } // Create a new child container to put project specific components - Container childModule = new ProjectTaskContainer(taskDefinition, reactor); + Container childModule = new ProjectTaskContainer(taskDefinition); try { installChild(childModule); childModule.start(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectTaskContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectTaskContainer.java index a5ea55a2da9..e63a411bdb3 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectTaskContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectTaskContainer.java @@ -22,12 +22,10 @@ package org.sonar.batch.bootstrap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.api.batch.bootstrap.ProjectReactor; import org.sonar.api.task.Task; import org.sonar.api.task.TaskDefinition; import org.sonar.api.utils.SonarException; import org.sonar.batch.DefaultFileLinesContextFactory; -import org.sonar.batch.ProjectConfigurator; import org.sonar.batch.ProjectTree; import org.sonar.batch.index.DefaultIndex; import org.sonar.batch.scan.ScanTask; @@ -46,16 +44,12 @@ public class ProjectTaskContainer extends Container { private TaskDefinition taskDefinition; - private ProjectReactor reactor; - - public ProjectTaskContainer(TaskDefinition task, ProjectReactor reactor) { + public ProjectTaskContainer(TaskDefinition task) { this.taskDefinition = task; - this.reactor = reactor; } @Override protected void configure() { - container.addSingleton(reactor); registerCoreProjectTasks(); registerCoreComponentsRequiringProject(); registerProjectTaskExtensions(); @@ -71,14 +65,10 @@ public class ProjectTaskContainer extends Container { } private void registerCoreComponentsRequiringProject() { - container.addSingleton(ProjectExclusions.class); - container.addSingleton(ProjectReactorReady.class); container.addSingleton(ProjectTree.class); - container.addSingleton(ProjectConfigurator.class); container.addSingleton(DefaultIndex.class); container.addSingleton(DefaultFileLinesContextFactory.class); container.addSingleton(ProjectLock.class); - container.addSingleton(DryRunDatabase.class); // graphs container.addSingleton(ScanGraph.create()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskBootstrapContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskBootstrapContainer.java index 8bc1d412bbe..22a60f8c162 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskBootstrapContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskBootstrapContainer.java @@ -34,11 +34,9 @@ import javax.annotation.Nullable; public class TaskBootstrapContainer extends Container { private String taskCommand; - private ProjectReactor reactor; - public TaskBootstrapContainer(@Nullable String taskCommand, @Nullable ProjectReactor reactor) { + public TaskBootstrapContainer(@Nullable String taskCommand) { this.taskCommand = taskCommand; - this.reactor = reactor; } @Override @@ -65,11 +63,11 @@ public class TaskBootstrapContainer extends Container { } private void executeTask(TaskDefinition taskDefinition) { - boolean projectPresent = (reactor != null); + boolean projectPresent = (container.getComponentByType(ProjectReactor.class) != null); if (ExtensionUtils.requiresProject(taskDefinition.getTask()) && !projectPresent) { throw new SonarException("Task '" + taskDefinition.getName() + "' requires to be run on a project"); } - Container childModule = new ProjectLessTaskContainer(taskDefinition, reactor); + Container childModule = new ProjectLessTaskContainer(taskDefinition, projectPresent); try { installChild(childModule); childModule.start(); diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskBootstrapContainerTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskBootstrapContainerTest.java index 148449bfce7..9e6b7320a2a 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskBootstrapContainerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskBootstrapContainerTest.java @@ -44,7 +44,7 @@ public class TaskBootstrapContainerTest { } }; bootstrapModule.init(); - TaskBootstrapContainer module = new TaskBootstrapContainer("inspect", null); + TaskBootstrapContainer module = new TaskBootstrapContainer("inspect"); bootstrapModule.installChild(module); thrown.expect(SonarException.class); diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java index ce956d6bd84..92cde480b91 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java @@ -20,8 +20,6 @@ package org.sonar.batch.bootstrap; import org.junit.Test; -import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.batch.bootstrap.ProjectReactor; import org.sonar.api.platform.ComponentContainer; import org.sonar.api.task.TaskDefinition; @@ -42,7 +40,7 @@ public class TaskContainerTest { } }; bootstrapModule.init(); - ProjectTaskContainer module = new ProjectTaskContainer(TaskDefinition.create(), new ProjectReactor(ProjectDefinition.create())); + ProjectTaskContainer module = new ProjectTaskContainer(TaskDefinition.create()); bootstrapModule.installChild(module); verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(true)); @@ -59,7 +57,7 @@ public class TaskContainerTest { } }; bootstrapModule.init(); - ProjectLessTaskContainer module = new ProjectLessTaskContainer(TaskDefinition.create(), null); + ProjectLessTaskContainer module = new ProjectLessTaskContainer(TaskDefinition.create(), false); bootstrapModule.installChild(module); verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(false)); |