diff --git a/src/org/redkale/boot/Application.java b/src/org/redkale/boot/Application.java index 79f49db3b..cf3a46259 100644 --- a/src/org/redkale/boot/Application.java +++ b/src/org/redkale/boot/Application.java @@ -232,7 +232,7 @@ public final class Application { } this.logger = Logger.getLogger(this.getClass().getSimpleName()); this.serversLatch = new CountDownLatch(config.getAnyValues("server").length + 1); - logger.log(Level.INFO, "------------------------------- Redkale -------------------------------"); + logger.log(Level.INFO, "------------------------------- Redkale 1.8 -------------------------------"); //------------------配置 节点 ------------------ ObjectPool transportPool = null; ExecutorService transportExec = null; @@ -295,10 +295,6 @@ public final class Application { return startTime; } - private void initLogging() { - - } - public void init() throws Exception { System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "" + Runtime.getRuntime().availableProcessors() * 4); System.setProperty("convert.bson.tiny", "true"); @@ -315,7 +311,7 @@ public final class Application { String lib = config.getValue("lib", "").trim().replace("${APP_HOME}", homepath); lib = lib.isEmpty() ? (homepath + "/conf") : (lib + ";" + homepath + "/conf"); Server.loadLib(logger, lib); - initLogging(); + //------------------------------------------------------------------------ final AnyValue resources = config.getAnyValue("resources"); if (resources != null) { @@ -569,7 +565,7 @@ public final class Application { runServers(timecd, others); runServers(timecd, watchs); //必须在所有server都启动后再启动 timecd.await(); - logger.info(this.getClass().getSimpleName() + " started in " + (System.currentTimeMillis() - startTime) + " ms"); + logger.info(this.getClass().getSimpleName() + " started in " + (System.currentTimeMillis() - startTime) + " ms\r\n"); if (!singletonrun) this.serversLatch.await(); } diff --git a/src/org/redkale/util/ResourceFactory.java b/src/org/redkale/util/ResourceFactory.java index 4b3509ae9..b7e2db124 100644 --- a/src/org/redkale/util/ResourceFactory.java +++ b/src/org/redkale/util/ResourceFactory.java @@ -499,7 +499,7 @@ public final class ResourceFactory { private static class ResourceElement { - private static final HashMap listenerMethods = new HashMap<>(); //不使用ConcurrentHashMap是因为value不能存null + private static final HashMap listenerMethods = new HashMap<>(); //不使用ConcurrentHashMap是因为value不能存null public final WeakReference dest; @@ -515,24 +515,27 @@ public final class ResourceFactory { this.fieldType = field.getType(); Class t = dest.getClass(); String tn = t.getName(); - this.listener = tn.startsWith("java.") || tn.startsWith("javax.") ? null : findListener(t); + this.listener = tn.startsWith("java.") || tn.startsWith("javax.") ? null : findListener(t, field.getType()); } - private static synchronized Method findListener(Class clazz) { + private static synchronized Method findListener(Class clazz, Class fieldType) { Class loop = clazz; - Method m = null; + Method m = listenerMethods.get(clazz.getName() + "-" + fieldType.getName()); + if (m != null) return m; do { for (Method method : loop.getDeclaredMethods()) { if (method.getAnnotation(ResourceListener.class) != null && method.getParameterCount() == 3 - && String.class.isAssignableFrom(method.getParameterTypes()[0])) { + && String.class.isAssignableFrom(method.getParameterTypes()[0]) + && method.getParameterTypes()[1] == method.getParameterTypes()[2] + && method.getParameterTypes()[1].isAssignableFrom(fieldType)) { m = method; m.setAccessible(true); break; } } } while ((loop = loop.getSuperclass()) != Object.class); - listenerMethods.put(clazz, m); + listenerMethods.put(clazz.getName() + "-" + fieldType.getName(), m); return m; } }