private Module bootstrapModule;
public Batch(ProjectReactor reactor, Object... bootstrapperComponents) {
- this.bootstrapModule = new BootstrapModule(reactor, bootstrapperComponents).init();
+ this.bootstrapModule = new BootstrapModule(reactor, bootstrapperComponents);
+ this.bootstrapModule.init();
}
/**
@Deprecated
public Batch(Configuration configuration, Object... bootstrapperComponents) {//NOSONAR configuration is not needed
// because it's already included in ProjectDefinition.
- this.bootstrapModule = new BootstrapModule(extractProjectReactor(bootstrapperComponents), bootstrapperComponents).init();
+ this.bootstrapModule = new BootstrapModule(extractProjectReactor(bootstrapperComponents), bootstrapperComponents);
+ this.bootstrapModule.init();
}
static ProjectReactor extractProjectReactor(Object[] components) {
analyze(subProject);
}
- Module projectComponents = installChild(new ProjectModule(project));
+ ProjectModule projectModule = new ProjectModule(project);
try {
- projectComponents.start();
+ installChild(projectModule);
+ projectModule.start();
} finally {
- projectComponents.stop();
+ projectModule.stop();
uninstallChild();
}
}
/**
* @return this
*/
- public final Module init() {
- return init(new ComponentContainer());
+ public final void init() {
+ init(new ComponentContainer());
}
/**
* @return this
*/
- private Module init(ComponentContainer container) {
+ private void init(ComponentContainer container) {
this.container = container;
configure();
- return this;
}
/**
private void startBatch() {
Module bootstrapModule = null;
try {
- bootstrapModule = new BootstrapModule(projectReactor, components.toArray(new Object[components.size()])).init();
+ bootstrapModule = new BootstrapModule(projectReactor, components.toArray(new Object[components.size()]));
+ bootstrapModule.init();
bootstrapModule.start();
} catch (RuntimeException e) {
PicoUtils.propagateStartupException(e);
@Test
public void shouldInitModule() {
- Module module = new FakeModule(FakeService.class).init();
+ Module module = new FakeModule(FakeService.class);
+ module.init();
FakeService service = module.container.getComponentByType(FakeService.class);
assertThat(service, not(nullValue()));
@Test
public void shouldStartAndStopModule() {
- Module module = new FakeModule(FakeService.class).init();
+ Module module = new FakeModule(FakeService.class);
+ module.init();
module.start();
FakeService service = module.container.getComponentByType(FakeService.class);
@Test(expected = RuntimeException.class)
public void shouldNotIgnoreStartFailures() {
- Module module = new FakeModule(NonStartableService.class).init();
+ Module module = new FakeModule(NonStartableService.class);
+ module.init();
module.start();
}
@Test
public void shouldIgnoreStopFailures() {
- Module module = new FakeModule(NonStoppableService.class).init();
+ Module module = new FakeModule(NonStoppableService.class);
+ module.init();
module.start();
module.stop(); // no exception is raised
}
@Test
public void componentsShouldBeSingletons() {
- Module module = new FakeModule(FakeService.class).init();
+ Module module = new FakeModule(FakeService.class);
+ module.init();
assertThat(module.container.getComponentByType(FakeService.class) == module.container.getComponentByType(FakeService.class), is(true));
}
@Test
public void shouldInstallChildModule() {
- Module parent = new FakeModule(FakeService.class).init();
+ Module parent = new FakeModule(FakeService.class);
+ parent.init();
parent.start();
Module child = parent.installChild(new FakeModule(ChildService.class));