From 52cf8e0f5ca85aef04d3a7c0802573ea139e2509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=B0=E5=B9=B3=E7=BA=BF?= <22250530@qq.com> Date: Sat, 30 May 2015 12:12:58 +0800 Subject: [PATCH] --- src/com/wentch/redkale/boot/Application.java | 40 ++++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/com/wentch/redkale/boot/Application.java b/src/com/wentch/redkale/boot/Application.java index d1550e371..0cc2eb4d6 100644 --- a/src/com/wentch/redkale/boot/Application.java +++ b/src/com/wentch/redkale/boot/Application.java @@ -33,8 +33,7 @@ import org.w3c.dom.*; /** * 编译时需要加入: -XDignore.symbol.file=true *

- * 进程启动类,程序启动后读取application.xml,进行classpath扫描动态加载Service与Servlet, - * 再进行Service、Servlet与其他资源之间的依赖注入。 + * 进程启动类,程序启动后读取application.xml,进行classpath扫描动态加载Service与Servlet, 再进行Service、Servlet与其他资源之间的依赖注入。 * * @author zhangjx */ @@ -178,6 +177,25 @@ public final class Application { System.setProperty("convert.json.pool.size", "128"); System.setProperty("convert.bson.writer.buffer.defsize", "4096"); System.setProperty("convert.json.writer.buffer.defsize", "4096"); + + final File root = new File(System.getProperty(RESNAME_HOME)); + this.factory.register(BsonFactory.root()); + this.factory.register(JsonFactory.root()); + this.factory.register(BsonFactory.root().getConvert()); + this.factory.register(JsonFactory.root().getConvert()); + File persist = new File(root, "conf/persistence.xml"); + if (persist.isFile()) System.setProperty(DataJDBCSource.DATASOURCE_CONFPATH, persist.getCanonicalPath()); + logger.log(Level.INFO, RESNAME_HOME + "=" + root.getCanonicalPath() + "\r\n" + RESNAME_ADDR + "=" + this.localAddress.getHostAddress()); + String lib = config.getValue("lib", "").trim().replace("${APP_HOME}", root.getCanonicalPath()); + lib = lib.isEmpty() ? (root.getCanonicalPath() + "/conf") : (lib + ";" + root.getCanonicalPath() + "/conf"); + Server.loadLib(logger, lib); + initLogging(); + InetAddress addr = Utility.localInetAddress(); + if (addr != null) { + byte[] bs = addr.getAddress(); + int v = (0xff & bs[bs.length - 2]) % 10 * 100 + (0xff & bs[bs.length - 1]); + this.factory.register("property.datasource.nodeid", "" + v); + } //------------------------------------------------------------------------ final AnyValue resources = config.getAnyValue("resources"); if (resources != null) { @@ -211,24 +229,6 @@ public final class Application { } } } - final File root = new File(System.getProperty(RESNAME_HOME)); - this.factory.register(BsonFactory.root()); - this.factory.register(JsonFactory.root()); - this.factory.register(BsonFactory.root().getConvert()); - this.factory.register(JsonFactory.root().getConvert()); - File persist = new File(root, "conf/persistence.xml"); - if (persist.isFile()) System.setProperty(DataJDBCSource.DATASOURCE_CONFPATH, persist.getCanonicalPath()); - logger.log(Level.INFO, RESNAME_HOME + "=" + root.getCanonicalPath() + "\r\n" + RESNAME_ADDR + "=" + this.localAddress.getHostAddress()); - String lib = config.getValue("lib", "").trim().replace("${APP_HOME}", root.getCanonicalPath()); - lib = lib.isEmpty() ? (root.getCanonicalPath() + "/conf") : (lib + ";" + root.getCanonicalPath() + "/conf"); - Server.loadLib(logger, lib); - initLogging(); - InetAddress addr = Utility.localInetAddress(); - if (addr != null) { - byte[] bs = addr.getAddress(); - int v = (0xff & bs[bs.length - 2]) % 10 * 100 + (0xff & bs[bs.length - 1]); - this.factory.register("property.datasource.nodeid", "" + v); - } initResources(); }