This commit is contained in:
@@ -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 -------------------------------");
|
||||
//------------------配置 <transport> 节点 ------------------
|
||||
ObjectPool<ByteBuffer> 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -499,7 +499,7 @@ public final class ResourceFactory {
|
||||
|
||||
private static class ResourceElement<T> {
|
||||
|
||||
private static final HashMap<Class, Method> listenerMethods = new HashMap<>(); //不使用ConcurrentHashMap是因为value不能存null
|
||||
private static final HashMap<String, Method> listenerMethods = new HashMap<>(); //不使用ConcurrentHashMap是因为value不能存null
|
||||
|
||||
public final WeakReference<T> 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user