From 704eae37eb0ac83ed612dc25327f5b66ce26530c Mon Sep 17 00:00:00 2001 From: Ian Date: Tue, 10 Sep 2024 12:06:47 +0300 Subject: [PATCH] FM2-642: Saner loading of GP listener --- .../java/org/openmrs/module/fhir2/FhirActivator.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/fhir2/FhirActivator.java b/api/src/main/java/org/openmrs/module/fhir2/FhirActivator.java index 03cb45e72..ccf19da8f 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/FhirActivator.java +++ b/api/src/main/java/org/openmrs/module/fhir2/FhirActivator.java @@ -80,10 +80,6 @@ public void started() { @Override public void willRefreshContext() { - if (globalPropertyHolder != null) { - Context.getAdministrationService().removeGlobalPropertyListener(globalPropertyHolder); - } - lifecycleListeners.forEach(ModuleLifecycleListener::willRefresh); unloadModules(); } @@ -92,12 +88,11 @@ public void willRefreshContext() { public void contextRefreshed() { if (globalPropertyHolder == null) { globalPropertyHolder = new FhirGlobalPropertyHolder(); + Context.getAdministrationService().addGlobalPropertyListener(globalPropertyHolder); } FhirGlobalPropertyHolder.reset(); - Context.getAdministrationService().addGlobalPropertyListener(globalPropertyHolder); - if (!started) { return; } @@ -111,7 +106,6 @@ public void contextRefreshed() { @Override public void willStop() { lifecycleListeners.forEach(ModuleLifecycleListener::willStop); - unloadModules(); if (globalPropertyHolder != null) { Context.getAdministrationService().removeGlobalPropertyListener(globalPropertyHolder); @@ -121,6 +115,7 @@ public void willStop() { @Override public void stopped() { lifecycleListeners.forEach(ModuleLifecycleListener::stopped); + unloadModules(); globalPropertyHolder = null; started = false;