Search in sources :

Example 1 with Initializer

use of org.sonar.api.batch.Initializer in project sonarqube by SonarSource.

the class InitializersExecutor method execute.

public void execute() {
    Collection<Initializer> initializers = selector.select(Initializer.class, module, true, null);
    eventBus.fireEvent(new InitializersPhaseEvent(Lists.newArrayList(initializers), true));
    if (LOG.isDebugEnabled()) {
        LOG.debug("Initializers : {}", StringUtils.join(initializers, " -> "));
    }
    Project project = new Project(module.definition());
    for (Initializer initializer : initializers) {
        eventBus.fireEvent(new InitializerExecutionEvent(initializer, true));
        Profiler profiler = Profiler.create(LOG).startInfo("Initializer " + initializer);
        initializer.execute(project);
        profiler.stopInfo();
        eventBus.fireEvent(new InitializerExecutionEvent(initializer, false));
    }
    eventBus.fireEvent(new InitializersPhaseEvent(Lists.newArrayList(initializers), false));
}
Also used : Project(org.sonar.api.resources.Project) Profiler(org.sonar.api.utils.log.Profiler) Initializer(org.sonar.api.batch.Initializer)

Example 2 with Initializer

use of org.sonar.api.batch.Initializer in project sonarqube by SonarSource.

the class PhasesSumUpTimeProfilerTest method initializerPhase.

private void initializerPhase(PhasesSumUpTimeProfiler profiler) {
    Initializer initializer = new FakeInitializer();
    // Start of initializer phase
    profiler.onInitializersPhase(initializersEvent(true));
    // Start of an initializer
    profiler.onInitializerExecution(initializerEvent(initializer, true));
    clock.sleep(7);
    // End of an initializer
    profiler.onInitializerExecution(initializerEvent(initializer, false));
    // End of initializer phase
    profiler.onInitializersPhase(initializersEvent(false));
}
Also used : Initializer(org.sonar.api.batch.Initializer)

Aggregations

Initializer (org.sonar.api.batch.Initializer)2 Project (org.sonar.api.resources.Project)1 Profiler (org.sonar.api.utils.log.Profiler)1