change: ConfigureLoader配置改成从 META-INF/nutz/org.nutz.boot.config.ConfigureLoader 读取

This commit is contained in:
Wendal Chen 2018-01-14 15:28:37 +08:00
parent ed89909aeb
commit 825489baa0

View File

@ -275,12 +275,17 @@ public class NbApp extends Thread {
public void prepareConfigureLoader() throws Exception { public void prepareConfigureLoader() throws Exception {
if (ctx.getConfigureLoader() == null) { if (ctx.getConfigureLoader() == null) {
String cnfLoader = ctx.getEnvHolder().get("nutz.boot.base.ConfigureLoader"); ConfigureLoader configureLoader = null;
ConfigureLoader configureLoader; InputStream ins = ctx.getResourceLoader().get("META-INF/nutz/org.nutz.boot.config.ConfigureLoader");
if (Strings.isBlank(cnfLoader)) { if (ins != null) {
String cnfLoader = new String(Streams.readBytes(ins)).trim();
if (!Strings.isBlank(cnfLoader)) {
log.debugf("using %s as ConfigureLoader", cnfLoader);
configureLoader = (ConfigureLoader) ctx.getClassLoader().loadClass(cnfLoader).newInstance();
}
}
if (configureLoader == null) {
configureLoader = new PropertiesConfigureLoader(); configureLoader = new PropertiesConfigureLoader();
} else {
configureLoader = (ConfigureLoader) ctx.getClassLoader().loadClass(cnfLoader).newInstance();
} }
configureLoader.setCommandLineProperties(allowCommandLineProperties, args); configureLoader.setCommandLineProperties(allowCommandLineProperties, args);
aware(configureLoader); aware(configureLoader);