添加版本删除
parent
9eec358731
commit
d49848af10
|
@ -82,11 +82,11 @@ public class RuleEngineVersionController {
|
||||||
@Operation(summary = "增加规则引擎版本",description = "通过传入版本添加的实体类,进行规则引擎的版本添加")
|
@Operation(summary = "增加规则引擎版本",description = "通过传入版本添加的实体类,进行规则引擎的版本添加")
|
||||||
public Result insertVersion(@Validated @RequestBody VersionAddReq versionAddReq){
|
public Result insertVersion(@Validated @RequestBody VersionAddReq versionAddReq){
|
||||||
|
|
||||||
boolean save = versionService.save(RuleEngineVersion.addBuild(versionAddReq));
|
//代码进行java编译,进行热加载
|
||||||
if (true==save){
|
boolean b = versionService.complierClass(versionAddReq.getClassName(), versionAddReq.getVersionClazz());
|
||||||
//添加成功则把增加的代码进行java编译,进行热加载
|
if (true==b){
|
||||||
versionService.complierClass(versionAddReq.getClassName(),versionAddReq.getVersionClazz());
|
boolean save = versionService.save(RuleEngineVersion.addBuild(versionAddReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
@ -238,9 +238,6 @@ Object o= versionService.readByOss(className);
|
||||||
return Result.success(o);
|
return Result.success(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id查询对应的版本
|
* 通过id查询对应的版本
|
||||||
* @param id
|
* @param id
|
||||||
|
|
|
@ -57,10 +57,12 @@ public interface RuleEngineVersionService extends IService<RuleEngineVersion> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对java源代码进行编译
|
* 对java源代码进行编译
|
||||||
* @param className 类名
|
*
|
||||||
|
* @param className 类名
|
||||||
* @param versionClazz 源代码
|
* @param versionClazz 源代码
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
void complierClass(String className, String versionClazz);
|
boolean complierClass(String className, String versionClazz);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.muyu.rule.common.domain.DataValueFie;
|
||||||
import com.muyu.rule.common.domain.DataValueRow;
|
import com.muyu.rule.common.domain.DataValueRow;
|
||||||
import com.muyu.rule.common.domain.DataValueRows;
|
import com.muyu.rule.common.domain.DataValueRows;
|
||||||
import com.muyu.rule.common.domain.RuleEngineVersion;
|
import com.muyu.rule.common.domain.RuleEngineVersion;
|
||||||
import com.muyu.rule.common.load.ExternalClassLoader;
|
|
||||||
import com.muyu.rule.common.utils.OssUtil;
|
import com.muyu.rule.common.utils.OssUtil;
|
||||||
import com.muyu.rule.server.mapper.RuleEngineVersionMapper;
|
import com.muyu.rule.server.mapper.RuleEngineVersionMapper;
|
||||||
import com.muyu.rule.server.service.RuleEngineVersionService;
|
import com.muyu.rule.server.service.RuleEngineVersionService;
|
||||||
|
@ -21,10 +20,6 @@ import org.springframework.stereotype.Service;
|
||||||
import javax.tools.JavaCompiler;
|
import javax.tools.JavaCompiler;
|
||||||
import javax.tools.ToolProvider;
|
import javax.tools.ToolProvider;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -133,11 +128,16 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编译
|
* 编译
|
||||||
* @param className 类名
|
*
|
||||||
|
* @param className 类名
|
||||||
* @param versionClazz 源代码
|
* @param versionClazz 源代码
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void complierClass(String className, String versionClazz) {
|
public boolean complierClass(String className, String versionClazz) {
|
||||||
|
|
||||||
|
boolean flag = true;
|
||||||
|
|
||||||
log.info("======>" + versionClazz);
|
log.info("======>" + versionClazz);
|
||||||
|
|
||||||
versionClazz = versionClazz.replace("<", "<").replace(">", ">");
|
versionClazz = versionClazz.replace("<", "<").replace(">", ">");
|
||||||
|
@ -169,11 +169,14 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
|
||||||
int i = javaCompiler.run(first, second, third, strings);
|
int i = javaCompiler.run(first, second, third, strings);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
System.out.println("成功");
|
System.out.println("成功");
|
||||||
|
flag=true;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("错误");
|
System.out.println("错误");
|
||||||
|
flag=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OssUtil.ssss(className);
|
OssUtil.ssss(className);
|
||||||
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue