Skip to content

Commit

Permalink
notify onLoad and onApply separately
Browse files Browse the repository at this point in the history
  • Loading branch information
g3force committed Oct 30, 2015
1 parent 49cc81e commit 5b4b8c1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.g3force</groupId>
<artifactId>configurable</artifactId>
<version>v1.4</version>
<version>v1.5</version>
<name>configurable</name>

<properties>
Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>com.github.g3force</groupId>
<artifactId>String2ValueConverter</artifactId>
<version>v1.5</version>
<version>v1.6</version>
</dependency>

<dependency>
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/github/g3force/configurable/AConfigClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,19 @@ public void notifyLoadConfig()
{
for (IConfigObserver o : observers)
{
o.onLoad(config);
o.onLoad(this);
}
}


/**
* @author Nicolai Ommer <nicolai.ommer@gmail.com>
*/
public void notifyAppliedConfig()
{
for (IConfigObserver o : observers)
{
o.afterApply(this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ public void applyConfig()
{
cap.loadConfiguration(getCurrentConfig());
cap.applyAll();
notifyAppliedConfig();
}
}
17 changes: 12 additions & 5 deletions src/main/java/com/github/g3force/configurable/IConfigObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
*/
package com.github.g3force.configurable;

import org.apache.commons.configuration.HierarchicalConfiguration;


/**
* Used to observe a config client
*
Expand All @@ -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)
{
}
}

0 comments on commit 5b4b8c1

Please sign in to comment.