This commit is contained in:
redkale
2023-12-15 22:55:27 +08:00
parent 387f1688f4
commit 6cb0a05720
3 changed files with 16 additions and 2 deletions

View File

@@ -483,7 +483,7 @@ class AppConfig {
}
}
static final AnyValue.MergeFunction appConfigmergeFunction = (path, key, val1, val2) -> {
static final AnyValue.MergeFunction APP_CONFIG_MERGE_FUNC = (path, key, val1, val2) -> {
if ("".equals(path)) {
if ("executor".equals(key)) {
return AnyValue.MergeFunction.REPLACE;

View File

@@ -248,8 +248,10 @@ public final class Application {
//设置基础信息资源
this.resourceFactory.register(RESNAME_APP_NAME, String.class, this.name);
this.resourceFactory.register(RESNAME_APP_NODEID, int.class, this.nodeid);
this.resourceFactory.register(RESNAME_APP_NODEID, Integer.class, this.nodeid);
this.resourceFactory.register(RESNAME_APP_TIME, long.class, this.startTime);
this.resourceFactory.register(RESNAME_APP_TIME, Long.class, this.startTime);
@@ -706,7 +708,7 @@ public final class Application {
Properties newDyncProps = new Properties();
dyncProps.forEach((k, v) -> newDyncProps.put(k.toString(), getPropertyValue(v.toString(), dyncProps)));
//合并配置
this.config.merge(AnyValue.loadFromProperties(newDyncProps).getAnyValue("redkale"), AppConfig.appConfigmergeFunction);
this.config.merge(AnyValue.loadFromProperties(newDyncProps).getAnyValue("redkale"), AppConfig.APP_CONFIG_MERGE_FUNC);
}
//使用合并后的新配置节点
propsConf = this.config.getAnyValue("properties");

View File

@@ -35,12 +35,24 @@ public abstract class AnyValue {
*/
public static interface MergeFunction {
/**
* 追加
*/
public static final int NONE = 0;
/**
* 替换
*/
public static final int REPLACE = 1;
/**
* 合并
*/
public static final int MERGE = 2;
/**
* 丢弃
*/
public static final int SKIP = 3;
public int apply(String path, String name, AnyValue val1, AnyValue val2);