|
@ -19,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
@ -209,15 +208,15 @@ public class ESBCamelService {
|
|
if (serviceFlowValid.is()) return Result.error("必要的入参数据不正确,请检查!");
|
|
if (serviceFlowValid.is()) return Result.error("必要的入参数据不正确,请检查!");
|
|
|
|
|
|
ServiceFlow serviceFlow = serviceFlowValid.getServiceFlow();
|
|
ServiceFlow serviceFlow = serviceFlowValid.getServiceFlow();
|
|
|
|
String routeCode = serviceFlow.getRouteCode();
|
|
|
|
SystemCamelContext.getContext().stopRoute(routeCode);
|
|
|
|
boolean b = SystemCamelContext.getContext().removeRoute(routeCode);
|
|
|
|
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles = serviceFlowValid.getHandleFiles();
|
|
ArrayList<ServiceFlow.HandleFile> handleFiles = serviceFlowValid.getHandleFiles();
|
|
if (handleFiles != null) {
|
|
if (handleFiles != null) {
|
|
for (ServiceFlow.HandleFile handleFile : handleFiles) {
|
|
for (ServiceFlow.HandleFile handleFile : handleFiles) {
|
|
String routeCode = serviceFlow.getRouteCode();
|
|
|
|
SystemCamelContext.getContext().stopRoute(routeCode);
|
|
|
|
SystemCamelContext.getContext().removeRoute(routeCode);
|
|
|
|
this.deleteClassFile(handleFile);
|
|
this.deleteClassFile(handleFile);
|
|
this.deleteServiceFlow(handleFile.getRouteCode());//删除mongo中serviceFlow信息
|
|
this.deleteServiceFlow(handleFile.getRouteCode());//删除mongo中serviceFlow信息
|
|
//TODO 删除mongodb中文件
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Result.success("服务流程删除成功!");
|
|
return Result.success("服务流程删除成功!");
|
|
@ -252,7 +251,7 @@ public class ESBCamelService {
|
|
if (!created[0]) {
|
|
if (!created[0]) {
|
|
System.out.println("processor 生成失败!");
|
|
System.out.println("processor 生成失败!");
|
|
return Result.error("服务流程启动失败!");
|
|
return Result.error("服务流程启动失败!");
|
|
}else {
|
|
|
|
|
|
} else {
|
|
System.out.println("processor 生成成功!");
|
|
System.out.println("processor 生成成功!");
|
|
}
|
|
}
|
|
|
|
|
|
@ -267,7 +266,7 @@ public class ESBCamelService {
|
|
if (!created[0]) {
|
|
if (!created[0]) {
|
|
System.out.println("route文件 生成失败!");
|
|
System.out.println("route文件 生成失败!");
|
|
return Result.error("服务流程启动失败!");
|
|
return Result.error("服务流程启动失败!");
|
|
}else {
|
|
|
|
|
|
} else {
|
|
System.out.println("route文件 生成成功!");
|
|
System.out.println("route文件 生成成功!");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@ -343,7 +342,7 @@ public class ESBCamelService {
|
|
String sourcePath = ClassFileUtil.downFile(downUrl, resource, handleFile.getPackageName(), handleFile.getClassName(), ClassFileUtil.JAVA_FILE);
|
|
String sourcePath = ClassFileUtil.downFile(downUrl, resource, handleFile.getPackageName(), handleFile.getClassName(), ClassFileUtil.JAVA_FILE);
|
|
|
|
|
|
if (sourcePath == null) {
|
|
if (sourcePath == null) {
|
|
System.out.println("下载java文件失败,downUrl:"+downUrl);
|
|
|
|
|
|
System.out.println("下载java文件失败,downUrl:" + downUrl);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@ -351,29 +350,36 @@ public class ESBCamelService {
|
|
boolean succ = CamelCompiler.compile(sourcePath, resource.getPath());
|
|
boolean succ = CamelCompiler.compile(sourcePath, resource.getPath());
|
|
if (succ) {
|
|
if (succ) {
|
|
//编译成功后将class文件上传至mongodb;文件名为类名+ routeCode
|
|
//编译成功后将class文件上传至mongodb;文件名为类名+ routeCode
|
|
String packagePath = StringUtil.replaceStrAll(handleFile.getPackageName(), ".", "/");
|
|
|
|
String classPath = resource.getPath() + packagePath + "/" + handleFile.getClassName() + ClassFileUtil.CLASS_FILE;
|
|
|
|
|
|
|
|
//上传文件
|
|
|
|
String fileName = handleFile.getClassName() + ClassFileUtil.CLASS_FILE;
|
|
|
|
String uploadUrl = fsUrl + "/" + handleFile.getFilePath();
|
|
|
|
ClassFileUtil.uploadFile(uploadUrl, new File(classPath), fileName);
|
|
|
|
}else {
|
|
|
|
System.out.println("编译失败,sourcePath:"+sourcePath);
|
|
|
|
|
|
// String packagePath = StringUtil.replaceStrAll(handleFile.getPackageName(), ".", "/");
|
|
|
|
// String classPath = this.getClass().getResource("/").getPath() + packagePath + "/" + handleFile.getClassName() + ClassFileUtil.CLASS_FILE;
|
|
|
|
//
|
|
|
|
// //上传文件
|
|
|
|
// String fileName = handleFile.getClassName() + ClassFileUtil.CLASS_FILE;
|
|
|
|
// ClassFileUtil.upload(fsUrl, classPath);
|
|
|
|
} else {
|
|
|
|
System.out.println("编译失败,sourcePath:" + sourcePath);
|
|
}
|
|
}
|
|
return succ;
|
|
return succ;
|
|
}
|
|
}
|
|
|
|
|
|
private void deleteClassFile(ServiceFlow.HandleFile handleFile) throws Exception {
|
|
|
|
String packagePath = StringUtil.replaceStrAll(handleFile.getPackageName(), ".", "/");
|
|
|
|
String classPath = ClassLoader.getSystemResource("").getPath() + "/" + packagePath + "/" + handleFile.getClassName() + ".class";
|
|
|
|
ClassFileUtil.deleteClassfile(classPath);
|
|
|
|
|
|
private void deleteClassFile(ServiceFlow.HandleFile handleFile) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
String packagePath = StringUtil.replaceStrAll(handleFile.getPackageName(), ".", "/");
|
|
|
|
String classPath = this.getClass().getResource("/").getPath() + "/" + packagePath + "/" + handleFile.getClassName() + ".class";
|
|
|
|
String javaPath = this.getClass().getResource("/").getPath() + "/" + packagePath + "/" + handleFile.getClassName() + ".java";
|
|
|
|
Boolean aBoolean = ClassFileUtil.deleteClassfile(javaPath);
|
|
|
|
Boolean bBoolean = ClassFileUtil.deleteClassfile(classPath);
|
|
|
|
//删除mongodb中文件
|
|
|
|
String delJavaUrl = fsUrl + "/" + handleFile.getFilePath();
|
|
|
|
ClassFileUtil.deleteFile(delJavaUrl);
|
|
|
|
|
|
String delJavaUrl = fsUrl + "/" + handleFile.getFilePath();
|
|
|
|
ClassFileUtil.deleteFile(delJavaUrl);
|
|
|
|
|
|
// 完成
|
|
|
|
logger.info("===================" + handleFile.getPackageName() + CoreConstant.DOT + handleFile.getClassName() + ".class 删除过程结束");
|
|
|
|
|
|
// 完成
|
|
|
|
logger.info("===================" + handleFile.getPackageName() + CoreConstant.DOT + handleFile.getClassName() + ".class 删除过程结束");
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|