From c77782b674bbb78c4f757493aab64112aac834b1 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Thu, 25 Apr 2024 22:15:38 +0200 Subject: [PATCH] Change channels used for firing configuration update events. --- .../src/org/jgrapes/util/NightConfigStore.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/org.jgrapes.util/src/org/jgrapes/util/NightConfigStore.java b/org.jgrapes.util/src/org/jgrapes/util/NightConfigStore.java index b03f0d8e7ea..59eb8bb3eaf 100644 --- a/org.jgrapes.util/src/org/jgrapes/util/NightConfigStore.java +++ b/org.jgrapes.util/src/org/jgrapes/util/NightConfigStore.java @@ -51,6 +51,7 @@ public abstract class NightConfigStore extends ConfigurationStore { = Logger.getLogger(NightConfigStore.class.getName()); protected FileConfig config; + protected Channel[] initialChannels; /** * Creates a new component with its channel set to the given @@ -128,18 +129,21 @@ public NightConfigStore(Channel componentChannel, File file, /** * If watching the configuration file is enabled, fire * a {@link ConfigurationUpdate} event with the complete - * configuration when the file changes. + * configuration when the file changes. The event is fired + * on the same channel(s) as the {@link InitialConfiguration} + * event. * * @param event the event */ @Handler(dynamic = true) public void onFileChanged(FileChanged event) { if (config.getNioPath().equals(event.path()) - && event.change() == FileChanged.Kind.MODIFIED) { + && event.change() == FileChanged.Kind.MODIFIED + && initialChannels != null) { config.load(); ConfigurationUpdate updEvt = new ConfigurationUpdate(); addPrefs(updEvt, "/", config); - fire(updEvt); + fire(updEvt, initialChannels); } } @@ -228,7 +232,8 @@ public void onStart(Start event) throws BackingStoreException, InterruptedException { ConfigurationUpdate updEvt = new InitialConfiguration(); addPrefs(updEvt, "/", config); - newEventPipeline().fire(updEvt, event.channels()).get(); + initialChannels = event.channels(); + newEventPipeline().fire(updEvt, initialChannels).get(); } private void addPrefs(ConfigurationUpdate updEvt, String path,