mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-04-27 14:42:16 +00:00
feat(agent-backend): adds wildcard character support for startContract.path in cmconfig.json
This commit is contained in:
parent
540a4232d0
commit
e9f7a9140b
@ -50,6 +50,7 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@ -166,6 +167,21 @@ public class CMHttpServer {
|
|||||||
|
|
||||||
private static void startByPath(JsonObject jo) {
|
private static void startByPath(JsonObject jo) {
|
||||||
String path = jo.get("path").getAsString();
|
String path = jo.get("path").getAsString();
|
||||||
|
if (path.indexOf('*') != -1) {
|
||||||
|
int split = Math.max(path.lastIndexOf('/'), 0);
|
||||||
|
String dirPath = path.substring(0, split), filePath = path.substring(split);
|
||||||
|
String[] fileName =
|
||||||
|
(filePath.startsWith("/") ? filePath.substring(1) : filePath).split("\\*");
|
||||||
|
File dir = new File(dirPath);
|
||||||
|
for (File file : Objects.requireNonNull(dir.listFiles())) {
|
||||||
|
LOGGER.warn(file.getName());
|
||||||
|
if (file.getName().startsWith(fileName[0])
|
||||||
|
&& file.getName().endsWith(fileName[fileName.length - 1])) {
|
||||||
|
path = file.getAbsolutePath();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File f = new File(path);
|
File f = new File(path);
|
||||||
if (!f.getName().endsWith(".ypk") || !f.exists())
|
if (!f.getName().endsWith(".ypk") || !f.exists())
|
||||||
return;
|
return;
|
||||||
@ -340,7 +356,7 @@ public class CMHttpServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadStartContractConfiguration() {
|
private void loadStartContractConfiguration() {
|
||||||
if (cmdConf.startContract != null && cmdConf.startContract.size() > 0) {
|
if (cmdConf.startContract != null && !cmdConf.startContract.isEmpty()) {
|
||||||
ContractManager.scheduledThreadPool.schedule(() -> {
|
ContractManager.scheduledThreadPool.schedule(() -> {
|
||||||
for (JsonElement je : cmdConf.startContract) {
|
for (JsonElement je : cmdConf.startContract) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user