diff --git a/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/bootstrap/validation/StartConfigurationValidator.java b/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/bootstrap/validation/StartConfigurationValidator.java index cc08560..9d031f5 100644 --- a/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/bootstrap/validation/StartConfigurationValidator.java +++ b/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/bootstrap/validation/StartConfigurationValidator.java @@ -212,7 +212,9 @@ public class StartConfigurationValidator { // === Helper methods for common validation patterns === /** - * Validates that a required path is not null, exists, and is a directory. + * Validates that a required directory path is not null, exists, and is a directory. + *
+ * Used for paths like source and target folders that must already exist before processing can begin.
*/
private void validateRequiredExistingDirectory(Path path, String fieldName, List
+ * The file itself may not exist yet (e.g., SQLite will create it on first use), but the parent
+ * directory must be present and writable. Used for files like sqlite.file where the application
+ * will create the file if needed.
*/
private void validateRequiredFileParentDirectory(Path filePath, String fieldName, List
- * Handles startup configuration validation before the batch application begins.
- * Validates mandatory fields, numeric ranges, URI schemes, and path existence.
- * Technical responsibility that does not belong to the application layer.
+ * Handles startup configuration validation as a separate step after configuration loading.
+ * Validates mandatory fields, numeric ranges, URI schemes, and path existence before
+ * the batch application begins. If validation fails, the application exits with code 1.
+ *
+ * Validation concerns include:
+ *
+ * This validation is a technical responsibility that does not belong to the application layer
+ * and is distinct from configuration loading. The validator is created and invoked by the
+ * bootstrap phase after configuration is loaded.
*/
package de.gecheckt.pdf.umbenenner.adapter.out.bootstrap.validation;
diff --git a/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/configuration/PropertiesConfigurationPortAdapter.java b/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/configuration/PropertiesConfigurationPortAdapter.java
index 7d1faa6..ecc5a97 100644
--- a/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/configuration/PropertiesConfigurationPortAdapter.java
+++ b/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/configuration/PropertiesConfigurationPortAdapter.java
@@ -20,8 +20,10 @@ import de.gecheckt.pdf.umbenenner.application.port.out.ConfigurationPort;
/**
* Properties-based implementation of {@link ConfigurationPort}.
*
- * Loads configuration from config/application.properties with environment variable
- * precedence for sensitive values like the API key.
+ * Loads configuration from config/application.properties as the primary source.
+ * For sensitive values, environment variables take precedence: if the environment variable
+ * {@code PDF_UMBENENNER_API_KEY} is set, it overrides the {@code api.key} property from the file.
+ * This allows credentials to be managed securely without storing them in the configuration file.
*/
public class PropertiesConfigurationPortAdapter implements ConfigurationPort {
diff --git a/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/configuration/package-info.java b/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/configuration/package-info.java
index ed71573..5a69e6b 100644
--- a/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/configuration/package-info.java
+++ b/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/configuration/package-info.java
@@ -1,12 +1,21 @@
/**
- * Configuration loading adapters.
+ * Configuration loading adapters for the bootstrap phase.
*
* Contains implementations of the {@link de.gecheckt.pdf.umbenenner.application.port.out.ConfigurationPort}
- * that load the {@link de.gecheckt.pdf.umbenenner.application.config.startup.StartConfiguration}
+ * that load the complete {@link de.gecheckt.pdf.umbenenner.application.config.startup.StartConfiguration}
* from external sources (e.g., properties files, environment variables).
*
+ * Responsibilities:
+ *
* These adapters bridge the outbound port contract with concrete infrastructure
- * (property file parsing, environment variable lookup) without leaking infrastructure
- * details into the application or bootstrap layers.
+ * (property file parsing, environment variable lookup) without leaking infrastructure details
+ * into the application or bootstrap layers. Validation of the loaded configuration is performed
+ * separately by the {@link de.gecheckt.pdf.umbenenner.adapter.out.bootstrap.validation.StartConfigurationValidator}
+ * in the bootstrap phase.
*/
package de.gecheckt.pdf.umbenenner.adapter.out.configuration;
\ No newline at end of file
diff --git a/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/BootstrapRunner.java b/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/BootstrapRunner.java
index 7ae707c..20a339d 100644
--- a/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/BootstrapRunner.java
+++ b/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/BootstrapRunner.java
@@ -41,17 +41,19 @@ import de.gecheckt.pdf.umbenenner.domain.model.BatchRunContext;
import de.gecheckt.pdf.umbenenner.domain.model.RunId;
/**
- * Manual bootstrap runner that constructs the object graph and drives the startup flow.
+ * Orchestrator for the complete startup sequence and object graph construction.
*
- * Responsibilities:
+ * Separates startup concerns into two distinct phases:
*
+ * The startup configuration encompasses all technical infrastructure and runtime parameters
+ * needed for bootstrap and execution. Once validated and the schema is initialized,
+ * configuration is handed to the use case factory which extracts the minimal runtime
+ * configuration for the application layer.
*
*
- * The production constructor wires the following adapters:
+ * The production constructor wires the following key adapters:
*
- * Schema initialisation is performed once in {@link #run()} before the batch loop starts.
- * A {@link DocumentPersistenceException} during schema initialisation is treated
- * as a hard startup failure and results in exit code 1.
+ * Schema initialization is performed exactly once in {@link #run()} before the batch processing loop
+ * begins. A {@link DocumentPersistenceException} during schema initialization is treated as a hard
+ * startup failure and results in exit code 1.
*/
public class BootstrapRunner {
@@ -122,12 +126,18 @@ public class BootstrapRunner {
}
/**
- * Functional interface for creating a BatchRunProcessingUseCase.
+ * Factory for creating a properly wired BatchRunProcessingUseCase.
*
- * Receives the full startup configuration (for infrastructure adapter wiring) and run lock port.
- * The factory extracts the runtime configuration and wires all outbound ports
- * required by the use case (e.g., source document port, PDF extraction port,
- * persistence and fingerprint ports).
+ * The factory receives the complete startup configuration (for infrastructure adapter wiring)
+ * and the run lock port. Its responsibility is to:
+ *
+ * This factory is the primary responsibility boundary between startup configuration
+ * (complete technical infrastructure setup) and runtime configuration (minimal application needs).
*/
@FunctionalInterface
public interface UseCaseFactory {
@@ -219,28 +229,31 @@ public class BootstrapRunner {
}
/**
- * Runs the application startup sequence.
+ * Runs the complete application startup sequence.
*
- * Startup flow:
+ * Startup flow consists of two phases:
*
- * Document-level failures during the batch loop are not startup failures and
- * do not change the exit code as long as the run itself completes without a hard
+ * A {@link DocumentPersistenceException} during schema initialization is treated as a hard startup
+ * failure and causes exit code 1. Document-level failures during the batch loop are not startup
+ * failures and do not change the exit code as long as the run itself completes without a hard
* infrastructure error.
*
- * @return exit code: 0 for a technically completed run, 1 for any hard startup or
- * bootstrap failure (configuration invalid, schema init failed, etc.)
+ * @return exit code: 0 for a technically completed run, 1 for any hard bootstrap,
+ * configuration, or persistence failure
*/
public int run() {
LOG.info("Bootstrap flow started.");
try {
+ // Bootstrap Phase: prepare configuration and persistence
StartConfiguration config = loadAndValidateConfiguration();
initializeSchema(config);
+ // Execution Phase: run batch processing
return executeWithStartConfiguration(config);
} catch (ConfigurationLoadingException e) {
LOG.error("Configuration loading failed: {}", e.getMessage());
@@ -280,13 +293,17 @@ public class BootstrapRunner {
/**
* Executes the batch processing pipeline with the prepared startup configuration.
*
- * Wires all runtime dependencies, constructs adapters and the batch use case,
- * invokes the CLI command, and maps the outcome to an exit code.
+ * Wires all runtime dependencies, constructs adapters and the batch use case via
+ * the use case factory, invokes the CLI command, and maps the outcome to an exit code.
+ *
+ * The use case factory is responsible for extracting the minimal runtime configuration
+ * from the complete startup configuration. This separation ensures the application layer
+ * depends only on the configuration it actually needs, following hexagonal architecture principles.
*
* This represents the execution phase after startup configuration is validated
* and persistence schema is initialized.
*
- * @param config the validated startup configuration
+ * @param config the validated startup configuration (complete technical configuration)
* @return exit code: 0 for batch completion, 1 for critical runtime failures
*/
private int executeWithStartConfiguration(StartConfiguration config) {
diff --git a/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/package-info.java b/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/package-info.java
index f120c0c..777414a 100644
--- a/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/package-info.java
+++ b/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/package-info.java
@@ -1,34 +1,46 @@
/**
* Bootstrap module for application startup and technical object graph construction.
*
- * Responsibility: Orchestrate the startup flow, load configuration, validate it,
- * create and wire all application components, and invoke the CLI adapter entry point.
+ * Responsibility: Orchestrate the complete startup sequence in two phases: (1) bootstrap phase
+ * for configuration loading, validation, and schema initialization, and (2) execution phase
+ * for wiring all adapters and running the batch processing pipeline.
*
* Components:
*
* Implementation approach:
*
* Startup sequence:
*
+ * Exit codes:
+ *
+ *
+ *
+ *
+ *
- *
+ * Exit code semantics
*
@@ -65,18 +67,20 @@ import de.gecheckt.pdf.umbenenner.domain.model.RunId;
*
*
Adapter wiring
*
- *
*
+ *
+ *
- *
*
*
*
- *
*
- *
+ *
+ *
*/
package de.gecheckt.pdf.umbenenner.bootstrap;
\ No newline at end of file