1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2024-09-19 20:25:51 +00:00

[3.1.0] fix(api): configuration reload problem

BREAKING CHANGES: Now we override "onReload()" method to define ConfigurationProvider how to reload the configs.

Fix the problem that when the configuration file is read, the "reload()" method not working.
This commit is contained in:
Carm Jos 2022-05-20 18:16:44 +08:00
parent 85bacb24f3
commit d6f4970277
7 changed files with 13 additions and 8 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyconfiguration-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>3.0.0</version>
<version>3.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>

View File

@ -26,10 +26,15 @@ public abstract class ConfigurationProvider<W extends ConfigurationWrapper> {
public abstract @NotNull W getConfiguration();
public abstract void reload() throws Exception;
public void reload() throws Exception {
onReload(); // 调用重写的Reload方法
this.updateTime = System.currentTimeMillis();
}
public abstract void save() throws Exception;
protected abstract void onReload() throws Exception;
public abstract void setHeaderComment(@Nullable String path, @Nullable List<String> comments);
public abstract void setInlineComment(@NotNull String path, @Nullable String comment);

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyconfiguration-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>3.0.0</version>
<version>3.1.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -49,7 +49,6 @@ public class JSONConfigProvider extends FileConfigProvider<JSONConfigWrapper> {
if (map == null) map = new LinkedHashMap<>();
this.configuration = new JSONConfigWrapper(map);
this.initializer = new ConfigInitializer<>(this);
}
@Override
@ -58,7 +57,8 @@ public class JSONConfigProvider extends FileConfigProvider<JSONConfigWrapper> {
}
@Override
public void reload() {
protected void onReload() throws Exception {
super.reload();
initializeConfig();
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyconfiguration-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>3.0.0</version>
<version>3.1.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -38,7 +38,7 @@ public class YAMLConfigProvider extends FileConfigProvider<YAMLSectionWrapper> {
}
@Override
public void reload() throws Exception {
protected void onReload() throws Exception {
configuration.load(getFile());
}

View File

@ -15,7 +15,7 @@
<groupId>cc.carm.lib</groupId>
<artifactId>easyconfiguration-parent</artifactId>
<packaging>pom</packaging>
<version>3.0.0</version>
<version>3.1.0</version>
<modules>
<module>core</module>
<module>impl/yaml</module>