Bootstrap-Refactoring: Init/Run-Trennung mit ApplicationRunContext
Führt ApplicationRunContext als package-private Record ein, der beim GUI-Start einmalig aus der validierten Konfiguration gebaut wird (migrate → load → validate → schema-init). Das Ergebnis wird in guiApplicationRunContext gecacht und von launchGuiBatchRun, launchGuiMiniBatchRun und resetDocumentStatusForGui wiederverwendet, sodass die Init-Sequenz nicht bei jedem Lauf wiederholt wird. GuiStartupContext erhält das neue Feld applicationContextError (Optional<String>), das einen deutschen Fehlertext trägt, wenn der Kontext bei Startup nicht initialisiert werden konnte. Alle bisherigen Konstruktoren und die blank()-Fabrik wurden rückwärtskompatibel ergänzt. Der Test-Helfer runnerWithGuiFactory wirft jetzt ConfigurationLoadingException statt AssertionError, damit initializeApplicationRunContext() den Fehler gracefully abfangen und in applicationContextError speichern kann. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-5
@@ -51,6 +51,11 @@ import de.gecheckt.pdf.umbenenner.domain.model.DocumentFingerprint;
|
||||
* context for documents that were skipped in the current run, and the resolved application
|
||||
* version string that the status bar displays at the bottom of the main window.
|
||||
* <p>
|
||||
* The optional {@code applicationContextError} carries a human-readable German error
|
||||
* message when the bootstrap-side application run context could not be initialised at
|
||||
* startup (e.g., invalid or incomplete configuration). An empty value signals that the
|
||||
* run context was built successfully and batch runs can be launched immediately.
|
||||
* <p>
|
||||
* All ports and services are supplied by Bootstrap so that the GUI adapter does not need to
|
||||
* know about provider-specific HTTP details or adapter wiring.
|
||||
*/
|
||||
@@ -78,7 +83,8 @@ public record GuiStartupContext(
|
||||
GuiHistoryResetDocumentStatusPort historyResetDocumentStatusPort,
|
||||
GuiDeleteDocumentHistoryPort deleteDocumentHistoryPort,
|
||||
GuiPromptEditorPortFactory promptEditorPortFactory,
|
||||
GuiCreateNewDatabasePort createNewDatabasePort) {
|
||||
GuiCreateNewDatabasePort createNewDatabasePort,
|
||||
Optional<String> applicationContextError) {
|
||||
|
||||
/**
|
||||
* Creates a fully wired startup context.
|
||||
@@ -111,10 +117,13 @@ public record GuiStartupContext(
|
||||
* {@code null} sein
|
||||
* @param promptEditorPortFactory Fabrik für Prompt-Editor-Ports bei Konfigurationswechsel;
|
||||
* darf nicht {@code null} sein
|
||||
* @param applicationContextError optional error message when the application run context
|
||||
* could not be initialised at startup; {@code null} becomes empty
|
||||
*/
|
||||
public GuiStartupContext {
|
||||
initialState = Objects.requireNonNull(initialState, "initialState must not be null");
|
||||
startupNotice = startupNotice == null ? Optional.empty() : startupNotice;
|
||||
applicationContextError = applicationContextError == null ? Optional.empty() : applicationContextError;
|
||||
configurationFileLoader = Objects.requireNonNull(configurationFileLoader,
|
||||
"configurationFileLoader must not be null");
|
||||
configurationFileWriter = Objects.requireNonNull(configurationFileWriter,
|
||||
@@ -202,7 +211,7 @@ public record GuiStartupContext(
|
||||
noOpHistoricalDocumentContextPort(), "dev", noOpPromptEditorPort(),
|
||||
noOpHistoryOverviewPort(), noOpHistoryDetailsPort(),
|
||||
noOpHistoryResetPort(), noOpDeleteHistoryPort(), noOpPromptEditorPortFactory(),
|
||||
rejectingCreateNewDatabasePort());
|
||||
rejectingCreateNewDatabasePort(), Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +250,7 @@ public record GuiStartupContext(
|
||||
noOpHistoricalDocumentContextPort(), "dev", noOpPromptEditorPort(),
|
||||
noOpHistoryOverviewPort(), noOpHistoryDetailsPort(),
|
||||
noOpHistoryResetPort(), noOpDeleteHistoryPort(), noOpPromptEditorPortFactory(),
|
||||
rejectingCreateNewDatabasePort());
|
||||
rejectingCreateNewDatabasePort(), Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,7 +289,7 @@ public record GuiStartupContext(
|
||||
noOpHistoricalDocumentContextPort(), "dev", noOpPromptEditorPort(),
|
||||
noOpHistoryOverviewPort(), noOpHistoryDetailsPort(),
|
||||
noOpHistoryResetPort(), noOpDeleteHistoryPort(), noOpPromptEditorPortFactory(),
|
||||
rejectingCreateNewDatabasePort());
|
||||
rejectingCreateNewDatabasePort(), Optional.empty());
|
||||
}
|
||||
|
||||
private static GuiBatchRunLauncher rejectingBatchRunLauncher() {
|
||||
@@ -403,7 +412,8 @@ public record GuiStartupContext(
|
||||
noOpHistoryResetPort(),
|
||||
noOpDeleteHistoryPort(),
|
||||
noOpPromptEditorPortFactory(),
|
||||
rejectingCreateNewDatabasePort());
|
||||
rejectingCreateNewDatabasePort(),
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user