Skip to content

Commit d7d3b86

Browse files
committed
feat: support TongWeb8
1 parent 824f71c commit d7d3b86

File tree

8 files changed

+611
-5
lines changed

8 files changed

+611
-5
lines changed

generator/src/main/java/com/reajason/javaweb/memshell/Server.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public enum Server {
101101
*/
102102
TongWeb6(new TongWeb6Shell()),
103103
TongWeb7(new TongWeb7Shell()),
104+
TongWeb8(new TongWeb8Shell()),
104105

105106
/**
106107
* 金蝶天燕中间件

generator/src/main/java/com/reajason/javaweb/memshell/generator/ValveGenerator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class ValveGenerator {
3131
public static final String BES_VALVE_PACKAGE = "com.bes.enterprise.webtier";
3232
public static final String TONGWEB6_VALVE_PACKAGE = "com.tongweb.web.thor";
3333
public static final String TONGWEB7_VALVE_PACKAGE = "com.tongweb.catalina";
34+
public static final String TONGWEB8_VALVE_PACKAGE = "com.tongweb.server";
3435

3536
public static class ValveRenameVisitorWrapper implements AsmVisitorWrapper {
3637
private final String newPackageName;

generator/src/main/java/com/reajason/javaweb/memshell/server/ServerToolRegistry.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public static void addToolMapping(ShellTool shellTool, ToolMapping toolMapping)
4141
shellClass = ValveGenerator.generateValveClass(ValveGenerator.TONGWEB7_VALVE_PACKAGE, shellClass);
4242
}
4343

44+
if (isValve && shell instanceof TongWeb8Shell) {
45+
shellClass = ValveGenerator.generateValveClass(ValveGenerator.TONGWEB8_VALVE_PACKAGE, shellClass);
46+
}
47+
4448
if (isValve && shell instanceof BesShell) {
4549
shellClass = ValveGenerator.generateValveClass(ValveGenerator.BES_VALVE_PACKAGE, shellClass);
4650
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.reajason.javaweb.memshell.server;
2+
3+
import com.reajason.javaweb.memshell.injector.tongweb.*;
4+
5+
import static com.reajason.javaweb.memshell.ShellType.*;
6+
7+
/**
8+
* @author ReaJason
9+
* @since 2024/12/27
10+
*/
11+
public class TongWeb8Shell extends AbstractShell {
12+
13+
@Override
14+
public Class<?> getListenerInterceptor() {
15+
return TomcatShell.ListenerInterceptor.class;
16+
}
17+
18+
@Override
19+
public InjectorMapping getShellInjectorMapping() {
20+
return InjectorMapping.builder()
21+
.addInjector(LISTENER, TongWebListenerInjector.class)
22+
.addInjector(JAKARTA_LISTENER, TongWebListenerInjector.class)
23+
.addInjector(FILTER, TongWebFilterInjector.class)
24+
.addInjector(JAKARTA_FILTER, TongWebFilterInjector.class)
25+
.addInjector(VALVE, TongWebValveInjector.class)
26+
.addInjector(JAKARTA_VALVE, TongWebValveInjector.class)
27+
.addInjector(AGENT_FILTER_CHAIN, TongWebFilterChainAgentInjector.class)
28+
.addInjector(CATALINA_AGENT_CONTEXT_VALVE, TongWebContextValveAgentInjector.class)
29+
.build();
30+
}
31+
}

memshell/src/main/java/com/reajason/javaweb/memshell/injector/tongweb/TongWebFilterInjector.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public TongWebFilterInjector() {
4949
* /opt/tweb6/lib/twnt.jar
5050
* com.tongweb.catalina.core.ApplicationContext
5151
* /opt/tweb7/lib/tongweb.jar
52+
* com.tongweb.server.core.ApplicationContext
53+
* /opt/tweb8/lib/tongweb-web.jar
5254
*/
5355
public List<Object> getContext() throws Exception {
5456
List<Object> contexts = new ArrayList<Object>();
@@ -102,14 +104,21 @@ public void inject(Object context, Object filter) throws Exception {
102104
ClassLoader contextClassLoader = context.getClass().getClassLoader();
103105
try {
104106
// tongweb 7
107+
constructor = contextClassLoader.loadClass("com.tongweb.catalina.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
105108
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
106109
filterMap = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap").newInstance();
107-
constructor = contextClassLoader.loadClass("com.tongweb.catalina.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
108110
} catch (Exception e2) {
109-
// tongweb 6
110-
filterDef = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterDef").newInstance();
111-
filterMap = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterMap").newInstance();
112-
constructor = contextClassLoader.loadClass("com.tongweb.web.thor.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
111+
try {
112+
// tongweb 6
113+
constructor = contextClassLoader.loadClass("com.tongweb.web.thor.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
114+
filterDef = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterDef").newInstance();
115+
filterMap = contextClassLoader.loadClass("com.tongweb.web.thor.deploy.FilterMap").newInstance();
116+
} catch (Exception e) {
117+
// tongweb 8
118+
constructor = contextClassLoader.loadClass("com.tongweb.server.core.ApplicationFilterConfig").getDeclaredConstructors()[0];
119+
filterDef = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterDef").newInstance();
120+
filterMap = contextClassLoader.loadClass("com.tongweb.web.util.descriptor.web.FilterMap").newInstance();
121+
}
113122
}
114123
invokeMethod(filterDef, "setFilterName", new Class[]{String.class}, new Object[]{filterClassName});
115124
invokeMethod(filterDef, "setFilterClass", new Class[]{String.class}, new Object[]{filterClassName});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.tongweb.server;
2+
3+
import com.tongweb.server.connector.Request;
4+
import com.tongweb.server.connector.Response;
5+
6+
import javax.servlet.ServletException;
7+
import java.io.IOException;
8+
9+
public interface Valve {
10+
Valve getNext();
11+
12+
void setNext(Valve var1);
13+
14+
void backgroundProcess();
15+
16+
void invoke(Request var1, Response var2) throws IOException, ServletException;
17+
18+
boolean isAsyncSupported();
19+
}

0 commit comments

Comments
 (0)