From 825489baa0d2382eddc89482950f56bbd99f8b23 Mon Sep 17 00:00:00 2001 From: Wendal Chen Date: Sun, 14 Jan 2018 15:28:37 +0800 Subject: [PATCH] =?UTF-8?q?change:=20ConfigureLoader=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=94=B9=E6=88=90=E4=BB=8E=20META-INF/nutz/org.nutz.boot.confi?= =?UTF-8?q?g.ConfigureLoader=20=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/nutz/boot/NbApp.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nutzboot-core/src/main/java/org/nutz/boot/NbApp.java b/nutzboot-core/src/main/java/org/nutz/boot/NbApp.java index e084aa38..9f6065d5 100644 --- a/nutzboot-core/src/main/java/org/nutz/boot/NbApp.java +++ b/nutzboot-core/src/main/java/org/nutz/boot/NbApp.java @@ -275,12 +275,17 @@ public class NbApp extends Thread { public void prepareConfigureLoader() throws Exception { if (ctx.getConfigureLoader() == null) { - String cnfLoader = ctx.getEnvHolder().get("nutz.boot.base.ConfigureLoader"); - ConfigureLoader configureLoader; - if (Strings.isBlank(cnfLoader)) { + ConfigureLoader configureLoader = null; + InputStream ins = ctx.getResourceLoader().get("META-INF/nutz/org.nutz.boot.config.ConfigureLoader"); + 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(); - } else { - configureLoader = (ConfigureLoader) ctx.getClassLoader().loadClass(cnfLoader).newInstance(); } configureLoader.setCommandLineProperties(allowCommandLineProperties, args); aware(configureLoader);