This commit is contained in:
@@ -267,7 +267,7 @@ public final class Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.transportFactory = new TransportFactory(transportExec, transportPool, transportGroup);
|
this.transportFactory = new TransportFactory(transportExec, transportPool, transportGroup);
|
||||||
this.classLoader = new NodeClassLoader(Thread.currentThread().getContextClassLoader());
|
this.classLoader = new NodeClassLoader((URLClassLoader)Thread.currentThread().getContextClassLoader());
|
||||||
Thread.currentThread().setContextClassLoader(this.classLoader);
|
Thread.currentThread().setContextClassLoader(this.classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.redkale.boot;
|
package org.redkale.boot;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +14,20 @@ import java.net.*;
|
|||||||
*/
|
*/
|
||||||
public class NodeClassLoader extends URLClassLoader {
|
public class NodeClassLoader extends URLClassLoader {
|
||||||
|
|
||||||
public NodeClassLoader(ClassLoader parent) {
|
private static final Method addURLMethod;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Method m = null;
|
||||||
|
try {
|
||||||
|
m = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
|
||||||
|
m.setAccessible(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
addURLMethod = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeClassLoader(URLClassLoader parent) {
|
||||||
super(new URL[0], parent);
|
super(new URL[0], parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +37,18 @@ public class NodeClassLoader extends URLClassLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addURL(URL url) {
|
public void addURL(URL url) {
|
||||||
super.addURL(url);
|
try {
|
||||||
|
addURLMethod.invoke(getParent(), url);
|
||||||
|
} catch (RuntimeException re) {
|
||||||
|
throw re;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URL[] getURLs() {
|
||||||
|
return ((URLClassLoader) getParent()).getURLs();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public abstract class NodeServer {
|
|||||||
this.resourceFactory = application.getResourceFactory().createChild();
|
this.resourceFactory = application.getResourceFactory().createChild();
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.logger = Logger.getLogger(this.getClass().getSimpleName());
|
this.logger = Logger.getLogger(this.getClass().getSimpleName());
|
||||||
this.classLoader = new NodeClassLoader(Thread.currentThread().getContextClassLoader());
|
this.classLoader = new NodeClassLoader((URLClassLoader)Thread.currentThread().getContextClassLoader());
|
||||||
Thread.currentThread().setContextClassLoader(this.classLoader);
|
Thread.currentThread().setContextClassLoader(this.classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user