diff --git a/src/org/redkale/boot/Application.java b/src/org/redkale/boot/Application.java index 101de81f9..2d77b37d5 100644 --- a/src/org/redkale/boot/Application.java +++ b/src/org/redkale/boot/Application.java @@ -338,6 +338,7 @@ public final class Application { String name = prop.getValue("name"); String value = prop.getValue("value"); if (name == null || value == null) continue; + value = value.replace("${APP_HOME}", home.getCanonicalPath()).replace('\\', '/'); if (name.startsWith("system.property.")) { System.setProperty(name.substring("system.property.".length()), value); } else if (name.startsWith("mimetype.property.")) { @@ -350,11 +351,6 @@ public final class Application { } } } - if (this.localAddress != null && this.resourceFactory.find("property.datasource.nodeid", String.class) == null) { - byte[] bs = this.localAddress.getAddress(); - int v = (0xff & bs[bs.length - 2]) % 10 * 100 + (0xff & bs[bs.length - 1]); - this.resourceFactory.register("property.datasource.nodeid", "" + v); - } this.resourceFactory.register(BsonFactory.root()); this.resourceFactory.register(JsonFactory.root()); this.resourceFactory.register(BsonFactory.root().getConvert()); diff --git a/src/org/redkale/boot/NodeServer.java b/src/org/redkale/boot/NodeServer.java index 2d3668eb4..240f08193 100644 --- a/src/org/redkale/boot/NodeServer.java +++ b/src/org/redkale/boot/NodeServer.java @@ -240,7 +240,7 @@ public abstract class NodeServer { logger.info("[" + Thread.currentThread().getName() + "] Load Service " + wrapper.getService()); } field.set(src, source); - rf.inject(source, self); // 给 "datasource.nodeid" 赋值; + rf.inject(source, self); // 给其可能包含@Resource的字段赋值; } catch (Exception e) { logger.log(Level.SEVERE, "DataSource inject error", e); } @@ -250,7 +250,7 @@ public abstract class NodeServer { resourceFactory.register((ResourceFactory rf, final Object src, final String resourceName, Field field, final Object attachment) -> { try { if (field.getAnnotation(Resource.class) == null) return; - if ((src instanceof Service) && Sncp.isRemote((Service) src)) return; //远程模式不得注入 CacheSource + if ((src instanceof Service) && Sncp.isRemote((Service) src)) return; //远程模式不需要注入 CacheSource SncpClient client = Sncp.getSncpClient((Service) src); Transport sameGroupTransport = Sncp.getSameGroupTransport((Service) src); diff --git a/src/org/redkale/net/sncp/Sncp.java b/src/org/redkale/net/sncp/Sncp.java index e66924292..3e1af99f9 100644 --- a/src/org/redkale/net/sncp/Sncp.java +++ b/src/org/redkale/net/sncp/Sncp.java @@ -55,11 +55,6 @@ public abstract class Sncp { private Sncp() { } - public static long nodeid(InetSocketAddress ip) { - byte[] bytes = ip.getAddress().getAddress(); - return ((0L + ip.getPort()) << 32) | ((0xffffffff & bytes[0]) << 24) | ((0xffffff & bytes[1]) << 16) | ((0xffff & bytes[2]) << 8) | (0xff & bytes[3]); - } - public static DLong hash(final java.lang.reflect.Method method) { if (method == null) return DLong.ZERO; StringBuilder sb = new StringBuilder(); //不能使用method.toString() 因为包含declaringClass信息导致接口与实现类的方法hash不一致