This commit is contained in:
@@ -94,33 +94,6 @@ public abstract class NodeServer {
|
|||||||
Thread.currentThread().setContextClassLoader(this.classLoader);
|
Thread.currentThread().setContextClassLoader(this.classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Consumer<Runnable> getExecutor() throws Exception {
|
|
||||||
if (server == null) return null;
|
|
||||||
final Field field = Server.class.getDeclaredField("context");
|
|
||||||
field.setAccessible(true);
|
|
||||||
return new Consumer<Runnable>() {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(Runnable t) {
|
|
||||||
if (context == null && server != null) {
|
|
||||||
try {
|
|
||||||
this.context = (Context) field.get(server);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.log(Level.SEVERE, "Server (" + server.getSocketAddress() + ") cannot find Context", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (context == null) {
|
|
||||||
t.run();
|
|
||||||
} else {
|
|
||||||
context.submitAsync(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T extends NodeServer> NodeServer create(Class<T> clazz, Application application, AnyValue serconf) {
|
public static <T extends NodeServer> NodeServer create(Class<T> clazz, Application application, AnyValue serconf) {
|
||||||
try {
|
try {
|
||||||
return clazz.getConstructor(Application.class, AnyValue.class).newInstance(application, serconf);
|
return clazz.getConstructor(Application.class, AnyValue.class).newInstance(application, serconf);
|
||||||
|
|||||||
Reference in New Issue
Block a user