Skip to content

Commit

Permalink
[3.1.0] fix(api): configuration reload problem
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CarmJos committed May 20, 2022
1 parent 85bacb2 commit d6f4970
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ public boolean isExpired(long time) {

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);
Expand Down
2 changes: 1 addition & 1 deletion impl/json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void initializeConfig() {
if (map == null) map = new LinkedHashMap<>();

this.configuration = new JSONConfigWrapper(map);
this.initializer = new ConfigInitializer<>(this);
}

@Override
Expand All @@ -58,7 +57,8 @@ public void initializeConfig() {
}

@Override
public void reload() {
protected void onReload() throws Exception {
super.reload();
initializeConfig();
}

Expand Down
2 changes: 1 addition & 1 deletion impl/yaml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void initializeConfig() {
}

@Override
public void reload() throws Exception {
protected void onReload() throws Exception {
configuration.load(getFile());
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit d6f4970

Please sign in to comment.