master
zhang chengzhi 2024-09-06 10:44:51 +08:00
parent 2ac0a1bdd8
commit 003440340d
1 changed files with 43 additions and 27 deletions

View File

@ -118,6 +118,14 @@ public static final String importClassAndPackPath="home/lib/";
*/ */
public static final String className_prefix = "com.muyu.rule.common.engine.value."; public static final String className_prefix = "com.muyu.rule.common.engine.value.";
/**
* class
* @param className
* @param versionClazz
*/
public static final String serverClassPath = "com/muyu/rule/common/engine/value/";
//todo //todo
@Override @Override
@ -169,10 +177,15 @@ public static final String importClassAndPackPath="home/lib/";
*/ */
@Override @Override
public void loadEngineClass(String className) { public void loadEngineClass(String className) {
//查询类是否已加载,避免重复加载规则引擎
if(!engineMap.containsKey(className)){
log.info("引擎map集合下没有该实例的容器,进行类加载");
try { try {
// 假设这是你的外部类文件路径 // 假设这是你的外部类文件路径
String externalClassFilePath = String externalClassFilePath =
importClassAndPackPath + "com/muyu/rule/common/engine/value/" + className + Suffix_CLASS; importClassAndPackPath + serverClassPath + className + Suffix_CLASS;
Path classFilePath = Paths.get(externalClassFilePath); Path classFilePath = Paths.get(externalClassFilePath);
String externalClassDir = externalClassFilePath.substring(0, externalClassFilePath.lastIndexOf('/')); String externalClassDir = externalClassFilePath.substring(0, externalClassFilePath.lastIndexOf('/'));
URL[] urls = new URL[]{new File(externalClassDir).toURI().toURL()}; URL[] urls = new URL[]{new File(externalClassDir).toURI().toURL()};
@ -202,6 +215,8 @@ public static final String importClassAndPackPath="home/lib/";
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}
// log.info("测试引擎是否成功类加载"); // log.info("测试引擎是否成功类加载");
// DataValue dataValue = DataValue.builder() // DataValue dataValue = DataValue.builder()
// .type("String") // .type("String")
@ -215,6 +230,7 @@ public static final String importClassAndPackPath="home/lib/";
// engine.execution(); // engine.execution();
} }
/** /**