1
0

Optimierung: BootstrapRunner weiter lesbarer und klarer strukturiert

This commit is contained in:
2026-04-06 08:09:28 +02:00
parent 6437ef38af
commit b5db3fb361

View File

@@ -226,9 +226,7 @@ public class BootstrapRunner {
* <li>Load and validate the configuration.</li>
* <li>Initialise the SQLite persistence schema. A {@link DocumentPersistenceException}
* here is a hard startup failure and causes exit code 1.</li>
* <li>Resolve the run-lock file path, apply default if not configured.</li>
* <li>Create the batch use case with all required adapters wired.</li>
* <li>Execute the CLI command and map the outcome to an exit code.</li>
* <li>Execute the batch processing pipeline with dependencies wired.</li>
* </ol>
* <p>
* Document-level failures during the batch loop are not startup failures and
@@ -243,13 +241,7 @@ public class BootstrapRunner {
try {
StartConfiguration config = loadAndValidateConfiguration();
initializeSchema(config);
RunLockPort runLockPort = runLockPortFactory.create(resolveLockFilePath(config));
BatchRunContext runContext = createRunContext();
BatchRunProcessingUseCase useCase = useCaseFactory.create(config, runLockPort);
SchedulerBatchCommand command = commandFactory.create(useCase);
BatchRunOutcome outcome = command.run(runContext);
runContext.setEndInstant(Instant.now());
return mapOutcomeToExitCode(outcome, runContext);
return executeWithStartConfiguration(config);
} catch (ConfigurationLoadingException e) {
LOG.error("Configuration loading failed: {}", e.getMessage());
return 1;
@@ -285,6 +277,28 @@ public class BootstrapRunner {
schemaInitPortFactory.create(buildJdbcUrl(config)).initializeSchema();
}
/**
* Executes the batch processing pipeline with the prepared startup configuration.
* <p>
* Wires all runtime dependencies, constructs adapters and the batch use case,
* invokes the CLI command, and maps the outcome to an exit code.
* <p>
* This represents the execution phase after startup configuration is validated
* and persistence schema is initialized.
*
* @param config the validated startup configuration
* @return exit code: 0 for batch completion, 1 for critical runtime failures
*/
private int executeWithStartConfiguration(StartConfiguration config) {
RunLockPort runLockPort = runLockPortFactory.create(resolveLockFilePath(config));
BatchRunContext runContext = createRunContext();
BatchRunProcessingUseCase useCase = useCaseFactory.create(config, runLockPort);
SchedulerBatchCommand command = commandFactory.create(useCase);
BatchRunOutcome outcome = command.run(runContext);
runContext.setEndInstant(Instant.now());
return mapOutcomeToExitCode(outcome, runContext);
}
/**
* Resolves the run-lock file path from the configuration, applying a default when not set.
*/