From d3315900b9d997d8fc9dd3000257476a2ca3b33e Mon Sep 17 00:00:00 2001 From: Minimons Date: Fri, 4 Sep 2026 08:32:14 +0200 Subject: [PATCH] X: NFC - Refactoring and additional logging --- .../nenjim/hubd/impl/ref/NenjimHubImpl.tjava | 107 +++++++++--------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava index 7f64dad..cb3b7a1 100644 --- a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava +++ b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava @@ -76,43 +76,37 @@ public final class NenjimHubImpl implements NenjimHub { "NenjimHub start has already been attempted"); } - Map processConstructors = - createProcessConstructorCatalogue(); - NenjimHubConfiguration configuration = - NenjimHubConfigurationParser.parse( - HUB_CONFIGURATION_PATH, - selectableProcessIds(processConstructors), - REGISTRY_SERVICE_ID, - JOURNAL_SERVICE_ID); + Map processConstructors = createProcessConstructorCatalogue(); + Set 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 processConstructors) + throws Exception { + List autoStartProcessIds = configuration + .autoStartProcessIds() + .subList(1, configuration.autoStartProcessIds().size()); + + for (NenjimComponentId componentId : autoStartProcessIds) { + constructRegisterAndStartProcess( + componentId, + processConstructors + ); + } + } + private NenjimProcess constructJournalProcess() { JournalServiceAssembly journalAssembly = JournalServiceAssembly.create(JOURNAL_ROOT); @@ -132,12 +140,17 @@ public final class NenjimHubImpl implements NenjimHub { private void initializeAndRegisterPassiveComponents( NenjimRegistryServiceManager registryServiceManager) { - initializeBuildingBlocks(registryServiceManager); + log.debug("Initializing components..."); + initializeComponents(registryServiceManager); + + log.debug("Initializing price sources..."); initializePriceSources(registryServiceManager); + + log.debug("Initializing passive services..."); initializePassiveServices(registryServiceManager); } - private void initializeBuildingBlocks( + private void initializeComponents( NenjimRegistryServiceManager registryServiceManager) { objectCache = new ObjectCacheImpl(); registryServiceManager.registerComponent(OBJECT_CACHE_ID, objectCache); @@ -359,33 +372,20 @@ public final class NenjimHubImpl implements NenjimHub { return Map.ofEntries( Map.entry(JOURNAL_SERVICE_ID, this::constructJournalProcess), Map.entry(TICKER_SERVICE_ID, this::constructTickerProcess), - Map.entry( - JUPITER_PERPS_ALARM_ID, - this::constructJupiterPerpsAlarmProcess), - Map.entry( - EVELYN_SERVICE_PROD_ID, - this::constructEvelynProdProcess), - Map.entry( - EVELYN_SERVICE_TEST_ID, - this::constructEvelynTestProcess), - Map.entry( - EVELYN_IOU_BURNER_PROD_ID, - this::constructEvelynIOUBurnerProdProcess), - Map.entry( - JAVAFX_RUNTIME_SERVICE_ID, - this::constructJavaFxRuntimeProcess), - Map.entry( - EVELYN_MISSION_CONTROL_ID, - this::constructMissionControlProcess), - Map.entry( - PROCESS_MANAGER_ID, - this::constructProcessManagerProcess)); + Map.entry(JUPITER_PERPS_ALARM_ID, this::constructJupiterPerpsAlarmProcess), + Map.entry(EVELYN_SERVICE_PROD_ID, this::constructEvelynProdProcess), + Map.entry(EVELYN_SERVICE_TEST_ID, this::constructEvelynTestProcess), + Map.entry(EVELYN_IOU_BURNER_PROD_ID, this::constructEvelynIOUBurnerProdProcess), + Map.entry(JAVAFX_RUNTIME_SERVICE_ID, this::constructJavaFxRuntimeProcess), + Map.entry(EVELYN_MISSION_CONTROL_ID, this::constructMissionControlProcess), + Map.entry(PROCESS_MANAGER_ID, this::constructProcessManagerProcess) + ); } private static Set selectableProcessIds( - Map processConstructors) { - Set processIds = - new HashSet<>(processConstructors.keySet()); + Map processConstructors + ) { + Set processIds = new HashSet<>(processConstructors.keySet()); processIds.add(REGISTRY_SERVICE_ID); return Set.copyOf(processIds); } @@ -416,6 +416,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 +535,7 @@ public final class NenjimHubImpl implements NenjimHub { private JavaFxRuntimeService javaFxRuntimeService; private EvelynMissionControl missionControl; private NenjimProcessManager processManager; + + // Internal state + private NenjimHubConfiguration configuration; }