优化PropertiesAgent.init接口参数
This commit is contained in:
@@ -807,13 +807,15 @@ public final class Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (PropertiesAgentProvider provider : InstanceProvider.sort(providers)) {
|
for (PropertiesAgentProvider provider : InstanceProvider.sort(providers)) {
|
||||||
|
long s = System.currentTimeMillis();
|
||||||
this.propertiesAgent = provider.createInstance();
|
this.propertiesAgent = provider.createInstance();
|
||||||
this.resourceFactory.inject(this.propertiesAgent);
|
this.resourceFactory.inject(this.propertiesAgent);
|
||||||
if (compileMode) {
|
if (compileMode) {
|
||||||
this.propertiesAgent.compile(propertiesConf);
|
this.propertiesAgent.compile(propertiesConf);
|
||||||
} else {
|
} else {
|
||||||
this.propertiesAgent.init(resourceFactory, appProperties, propertiesConf);
|
this.propertiesAgent.init(resourceFactory, appProperties, sourceProperties, propertiesConf);
|
||||||
}
|
}
|
||||||
|
logger.info("PropertiesAgent (type = " + this.propertiesAgent.getClass().getSimpleName() + ") init in " + (System.currentTimeMillis() - s) + " ms");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,10 @@ public abstract class PropertiesAgent {
|
|||||||
*
|
*
|
||||||
* @param factory 依赖注入资源工厂
|
* @param factory 依赖注入资源工厂
|
||||||
* @param appProperties 全局property.开头的配置项
|
* @param appProperties 全局property.开头的配置项
|
||||||
|
* @param sourceProperties 全局source数据源的配置项
|
||||||
* @param conf 节点配置
|
* @param conf 节点配置
|
||||||
*/
|
*/
|
||||||
public abstract void init(ResourceFactory factory, Properties appProperties, AnyValue conf);
|
public abstract void init(ResourceFactory factory, Properties appProperties, Properties sourceProperties, AnyValue conf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销毁动作
|
* 销毁动作
|
||||||
@@ -56,6 +57,21 @@ public abstract class PropertiesAgent {
|
|||||||
public abstract void destroy(AnyValue conf);
|
public abstract void destroy(AnyValue conf);
|
||||||
|
|
||||||
protected String getKeyResourceName(String key) {
|
protected String getKeyResourceName(String key) {
|
||||||
return key.startsWith("system.property.") || key.startsWith("property.") ? key : ("property." + key);
|
return key.startsWith("redkale.")
|
||||||
|
|| key.startsWith("property.")
|
||||||
|
|| key.startsWith("system.property.")
|
||||||
|
|| key.startsWith("mimetype.property.") ? key : ("property." + key);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void putProperties(Properties appProperties, Properties sourceProperties, Properties newProps) {
|
||||||
|
newProps.forEach((k, v) -> putProperties(appProperties, sourceProperties, k.toString(), v));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void putProperties(Properties appProperties, Properties sourceProperties, String key, Object value) {
|
||||||
|
if (key.startsWith("redkale.datasource.") || key.startsWith("redkale.datasource[")
|
||||||
|
|| key.startsWith("redkale.cachesource.") || key.startsWith("redkale.cachesource[")) {
|
||||||
|
sourceProperties.put(key, value);
|
||||||
|
}
|
||||||
|
appProperties.put(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user