X: NFC - Refactoring and additional logging
This commit is contained in:
@@ -76,43 +76,37 @@ public final class NenjimHubImpl implements NenjimHub {
|
||||
"NenjimHub start has already been attempted");
|
||||
}
|
||||
|
||||
Map<NenjimComponentId, ProcessConstructor> processConstructors =
|
||||
createProcessConstructorCatalogue();
|
||||
NenjimHubConfiguration configuration =
|
||||
NenjimHubConfigurationParser.parse(
|
||||
HUB_CONFIGURATION_PATH,
|
||||
selectableProcessIds(processConstructors),
|
||||
REGISTRY_SERVICE_ID,
|
||||
JOURNAL_SERVICE_ID);
|
||||
Map<NenjimComponentId, ProcessConstructor> processConstructors = createProcessConstructorCatalogue();
|
||||
Set<NenjimComponentId> knownProcessIds = selectableProcessIds(processConstructors);
|
||||
|
||||
log.info("Initializing Nenjim Registry...");
|
||||
NenjimRegistryAssembly registryAssembly =
|
||||
NenjimRegistryAssembly.create();
|
||||
registryService =
|
||||
registryAssembly.registryService();
|
||||
log.debug("Parsing Nenjim configuration...");
|
||||
configuration = NenjimHubConfigurationParser.parse(
|
||||
HUB_CONFIGURATION_PATH,
|
||||
knownProcessIds,
|
||||
REGISTRY_SERVICE_ID,
|
||||
JOURNAL_SERVICE_ID
|
||||
);
|
||||
|
||||
log.debug("Initializing Nenjim Registry...");
|
||||
NenjimRegistryAssembly registryAssembly = NenjimRegistryAssembly.create();
|
||||
registryService = registryAssembly.registryService();
|
||||
NenjimProcess registryProcess = registryAssembly.registryProcess();
|
||||
registryServiceManager = registryAssembly.registryServiceManager();
|
||||
|
||||
registryProcess.start();
|
||||
registryServiceManager.registerComponent(
|
||||
REGISTRY_SERVICE_ID,
|
||||
registryService);
|
||||
registryService
|
||||
);
|
||||
recordStartedProcess(REGISTRY_SERVICE_ID);
|
||||
|
||||
log.info("Initializing passive Nenjim components...");
|
||||
log.debug("Initializing passive Nenjim components...");
|
||||
initializeAndRegisterPassiveComponents(registryServiceManager);
|
||||
|
||||
log.info("Constructing and starting configured Nenjim processes...");
|
||||
for (NenjimComponentId componentId
|
||||
: configuration.autoStartProcessIds().subList(
|
||||
1,
|
||||
configuration.autoStartProcessIds().size())) {
|
||||
constructRegisterAndStartProcess(
|
||||
componentId,
|
||||
processConstructors);
|
||||
}
|
||||
log.info("Auto-starting configured Nenjim processes...");
|
||||
autoStartProcesses(processConstructors);
|
||||
|
||||
System.out.println("Done - Now online!");
|
||||
log.info("Done - Now online!");
|
||||
|
||||
waitForAndShutdown();
|
||||
}
|
||||
@@ -123,6 +117,20 @@ public final class NenjimHubImpl implements NenjimHub {
|
||||
return List.copyOf(startedProcessIds);
|
||||
}
|
||||
|
||||
private void autoStartProcesses(Map<NenjimComponentId, ProcessConstructor> processConstructors)
|
||||
throws Exception {
|
||||
List<NenjimComponentId> autoStartProcessIds = configuration
|
||||
.autoStartProcessIds()
|
||||
.subList(1, configuration.autoStartProcessIds().size());
|
||||
|
||||
for (NenjimComponentId componentId : autoStartProcessIds) {
|
||||
constructRegisterAndStartProcess(
|
||||
componentId,
|
||||
processConstructors
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private NenjimProcess constructJournalProcess() {
|
||||
JournalServiceAssembly journalAssembly =
|
||||
JournalServiceAssembly.create(JOURNAL_ROOT);
|
||||
@@ -416,6 +424,8 @@ public final class NenjimHubImpl implements NenjimHub {
|
||||
+ "' is not registered as "
|
||||
+ NenjimProcess.class.getName());
|
||||
}
|
||||
|
||||
log.info("Starting process '" + componentId.value() + "'...");
|
||||
process.start();
|
||||
recordStartedProcess(componentId);
|
||||
}
|
||||
@@ -533,4 +543,7 @@ public final class NenjimHubImpl implements NenjimHub {
|
||||
private JavaFxRuntimeService javaFxRuntimeService;
|
||||
private EvelynMissionControl missionControl;
|
||||
private NenjimProcessManager processManager;
|
||||
|
||||
// Internal state
|
||||
private NenjimHubConfiguration configuration;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user