From 5b4b8c12af186b64be6fad1335436b908cbaf94c Mon Sep 17 00:00:00 2001 From: Nicolai Ommer Date: Fri, 30 Oct 2015 20:25:45 +0100 Subject: [PATCH] notify onLoad and onApply separately --- pom.xml | 4 ++-- .../g3force/configurable/AConfigClient.java | 14 +++++++++++++- .../g3force/configurable/ConfigClient.java | 1 + .../g3force/configurable/IConfigObserver.java | 17 ++++++++++++----- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index c08847b..bc37679 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.github.g3force configurable - v1.4 + v1.5 configurable @@ -27,7 +27,7 @@ com.github.g3force String2ValueConverter - v1.5 + v1.6 diff --git a/src/main/java/com/github/g3force/configurable/AConfigClient.java b/src/main/java/com/github/g3force/configurable/AConfigClient.java index 0a74c59..165afed 100644 --- a/src/main/java/com/github/g3force/configurable/AConfigClient.java +++ b/src/main/java/com/github/g3force/configurable/AConfigClient.java @@ -140,7 +140,19 @@ public void notifyLoadConfig() { for (IConfigObserver o : observers) { - o.onLoad(config); + o.onLoad(this); + } + } + + + /** + * @author Nicolai Ommer + */ + public void notifyAppliedConfig() + { + for (IConfigObserver o : observers) + { + o.afterApply(this); } } diff --git a/src/main/java/com/github/g3force/configurable/ConfigClient.java b/src/main/java/com/github/g3force/configurable/ConfigClient.java index 0b3976a..746e26c 100644 --- a/src/main/java/com/github/g3force/configurable/ConfigClient.java +++ b/src/main/java/com/github/g3force/configurable/ConfigClient.java @@ -97,5 +97,6 @@ public void applyConfig() { cap.loadConfiguration(getCurrentConfig()); cap.applyAll(); + notifyAppliedConfig(); } } diff --git a/src/main/java/com/github/g3force/configurable/IConfigObserver.java b/src/main/java/com/github/g3force/configurable/IConfigObserver.java index 6fb4642..6338cbc 100644 --- a/src/main/java/com/github/g3force/configurable/IConfigObserver.java +++ b/src/main/java/com/github/g3force/configurable/IConfigObserver.java @@ -8,9 +8,6 @@ */ package com.github.g3force.configurable; -import org.apache.commons.configuration.HierarchicalConfiguration; - - /** * Used to observe a config client * @@ -19,7 +16,17 @@ public interface IConfigObserver { /** - * @param newConfig + * @param configClient + */ + default void afterApply(final IConfigClient configClient) + { + } + + + /** + * @param configClient */ - void onLoad(HierarchicalConfiguration newConfig); + default void onLoad(final IConfigClient configClient) + { + } }