public boolean setRequestTmp(org.apache.catalina.connector.Request tmpRequest) {
System.err.println("requestInfo------------>" + this.getClass().getClassLoader());
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Class<?> forName = Class.forName(tmpRequest.getClass().getName(), true, loader);
System.err.println(forName.getName() + ":" + forName + ":" + forName.getClassLoader());
Method method = tmpRequest.getClass().getDeclaredMethod("getHost", null);
Object invoke = method.invoke(tmpRequest.getClass().newInstance(), null);
Object invoke1 = method.invoke(forName.newInstance(), null);
System.out.println(invoke);
System.out.println(invoke1);
ServiceLoader<Request> loader1 = (ServiceLoader<Request>) ServiceLoader.load(tmpRequest.getClass());
Iterator<Request> iterator = loader1.iterator();
while (iterator.hasNext()) {
Request driver = (Request) iterator.next();
System.out.println("driver:" + driver.getClass() + ",loader:" + driver.getClass().getClassLoader());
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (tmpRequest != null) {
HttpSession session = tmpRequest.getSession();
}
return false;
}
一个疑问,模拟bootstrap获取webappclassloader的class却不成功,无语了。
最新推荐文章于 2024-08-07 00:11:00 发布