상수화
This commit is contained in:
@@ -2,26 +2,26 @@ package com.eactive.httpmockserver.script;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.mdkt.compiler.CompilationException;
|
||||
import org.mdkt.compiler.CompiledCode;
|
||||
import org.mdkt.compiler.DynamicClassLoader;
|
||||
import org.mdkt.compiler.InMemoryJavaCompiler;
|
||||
|
||||
import javax.tools.*;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ScriptLoader{
|
||||
String path = ScriptLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
public static String DYNAMIC_BASE_PACKAGE = "com.eactive.httpmockserver.script.dynamic";
|
||||
public static String DYNAMIC_BASE_PATH = DYNAMIC_BASE_PACKAGE.replaceAll("[.]","/");
|
||||
public static String JAR_PREFIX = SystemUtils.IS_OS_WINDOWS ? "jar:file:/" : "jar:file:";
|
||||
public static String CLASS_PATH_SEPARATOR = System.getProperty("path.separator");
|
||||
|
||||
|
||||
private static final ScriptLoader instance = new ScriptLoader();
|
||||
private Map<String, Class<Script>> loadedClass;
|
||||
@@ -39,9 +39,8 @@ public class ScriptLoader{
|
||||
String uri = url.toURI().toString();
|
||||
System.out.println(uri);
|
||||
if(StringUtils.contains(uri, "jar:file:" )) {
|
||||
String prefix = SystemUtils.IS_OS_WINDOWS ? "jar:file:/" : "jar:file:";
|
||||
|
||||
String jarPath = StringUtils.substringBetween(uri, prefix, ".jar!") + ".jar";
|
||||
String jarPath = StringUtils.substringBetween(uri, JAR_PREFIX, ".jar!") + ".jar";
|
||||
System.out.println("jarPath => " + jarPath);
|
||||
|
||||
if(StringUtils.contains(uri, "BOOT-INF" )) {
|
||||
@@ -74,7 +73,7 @@ public class ScriptLoader{
|
||||
bos.close();
|
||||
}
|
||||
jar.close();
|
||||
classPath = memoryWorkingPath+"/BOOT-INF/classes"+System.getProperty("path.separator")+memoryWorkingPath+"/BOOT-INF/lib/*"+System.getProperty("path.separator");
|
||||
classPath = memoryWorkingPath+"/BOOT-INF/classes"+CLASS_PATH_SEPARATOR+memoryWorkingPath+"/BOOT-INF/lib/*"+CLASS_PATH_SEPARATOR;
|
||||
}else {
|
||||
classPath = jarPath;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user