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:
parent
85bacb24f3
commit
d6f4970277
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -26,10 +26,15 @@ public abstract class ConfigurationProvider<W extends ConfigurationWrapper> {
|
|||||||
|
|
||||||
public abstract @NotNull W getConfiguration();
|
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;
|
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 setHeaderComment(@Nullable String path, @Nullable List<String> comments);
|
||||||
|
|
||||||
public abstract void setInlineComment(@NotNull String path, @Nullable String comment);
|
public abstract void setInlineComment(@NotNull String path, @Nullable String comment);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -49,7 +49,6 @@ public class JSONConfigProvider extends FileConfigProvider<JSONConfigWrapper> {
|
|||||||
if (map == null) map = new LinkedHashMap<>();
|
if (map == null) map = new LinkedHashMap<>();
|
||||||
|
|
||||||
this.configuration = new JSONConfigWrapper(map);
|
this.configuration = new JSONConfigWrapper(map);
|
||||||
this.initializer = new ConfigInitializer<>(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,7 +57,8 @@ public class JSONConfigProvider extends FileConfigProvider<JSONConfigWrapper> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() {
|
protected void onReload() throws Exception {
|
||||||
|
super.reload();
|
||||||
initializeConfig();
|
initializeConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -38,7 +38,7 @@ public class YAMLConfigProvider extends FileConfigProvider<YAMLSectionWrapper> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() throws Exception {
|
protected void onReload() throws Exception {
|
||||||
configuration.load(getFile());
|
configuration.load(getFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -15,7 +15,7 @@
|
|||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>impl/yaml</module>
|
<module>impl/yaml</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user