|
@ -64,7 +64,7 @@ public class ESBCamelService {
|
|
|
SystemCamelContext.getDefaultCamelContext().removeRoute(serviceFlow);
|
|
|
|
|
|
DynamicClassLoader classLoader = new DynamicClassLoader(DynamicClassLoader.class.getClassLoader());
|
|
|
Class<RouteBuilder> routeBuilderClass = (Class<RouteBuilder>) classLoader.loadClass(ClassLoader.getSystemResource(CoreConstant.EMPTY).getPath(), SystemClassMapping.getSystemClassNameMapping().get(serviceFlow + BrokerConstant.ROUTE));
|
|
|
Class<RouteBuilder> routeBuilderClass = (Class<RouteBuilder>) classLoader.loadClass(this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath(), SystemClassMapping.getSystemClassNameMapping().get(serviceFlow + BrokerConstant.ROUTE));
|
|
|
classLoader.loadClass(ClassLoader.getSystemResource(CoreConstant.EMPTY).getPath(), SystemClassMapping.getSystemClassNameMapping().get(serviceFlow + BrokerConstant.PROCESSOR));
|
|
|
|
|
|
if (routeBuilderClass != null) {
|
|
@ -88,10 +88,6 @@ public class ESBCamelService {
|
|
|
logger.error("必要的入参数据不正确,请检查!");
|
|
|
return Result.error("必要的入参数据不正确,请检查!");
|
|
|
}
|
|
|
File systemClassRootPath = new File(ClassLoader.getSystemResource("").getPath() + "/" + serviceFlow);
|
|
|
if (!systemClassRootPath.exists()) {
|
|
|
systemClassRootPath.mkdirs();
|
|
|
}
|
|
|
// 第1、2两步处理过程,都是在这里完成
|
|
|
this.createClassfile(serviceFlow, packageName, className, path, BrokerConstant.ROUTE);
|
|
|
|
|
@ -194,9 +190,9 @@ public class ESBCamelService {
|
|
|
|
|
|
private void createClassfile(String serviceFlow, String packageName, String className, String path, String type) throws MalformedURLException {
|
|
|
// 1、============
|
|
|
File systemClassFlowPath = new File(ClassLoader.getSystemResource(CoreConstant.EMPTY).getPath() + "/" + serviceFlow);
|
|
|
File systemClassFlowPath = new File(this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath());
|
|
|
// 记录到工具类中,以便其它线程需要时进行取用
|
|
|
SystemClassMapping.getSystemClassNameMapping().put(serviceFlow + type, serviceFlow + CoreConstant.DOT + packageName + CoreConstant.DOT + className);
|
|
|
SystemClassMapping.getSystemClassNameMapping().put(serviceFlow + type, packageName + CoreConstant.DOT + className);
|
|
|
|
|
|
// 2、============开始写入class文件
|
|
|
ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, path);
|
|
@ -211,7 +207,8 @@ public class ESBCamelService {
|
|
|
if(StringUtil.isEmpty(systemClassName)) {
|
|
|
return;
|
|
|
}
|
|
|
String classPath = ClassLoader.getSystemResource("").getPath() + "/" + serviceFlow + "/" + packageName + "/" + className + ".class";
|
|
|
String packagePath = StringUtil.replaceStrAll(packageName, ".", "/");
|
|
|
String classPath = this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath() + packagePath + "/" + className + ".class";
|
|
|
// 2、============开始写入class文件
|
|
|
ClassFileUtil.updateClassfile(classPath, path);
|
|
|
// 完成
|
|
@ -225,7 +222,8 @@ public class ESBCamelService {
|
|
|
if(StringUtil.isEmpty(systemClassName)) {
|
|
|
return;
|
|
|
}
|
|
|
String classPath = ClassLoader.getSystemResource("").getPath() + "/" + serviceFlow + "/" + packageName + "/" + className + ".class";
|
|
|
String packagePath = StringUtil.replaceStrAll(packageName, ".", "/");
|
|
|
String classPath = ClassLoader.getSystemResource("").getPath() + "/" + packagePath + "/" + className + ".class";
|
|
|
|
|
|
// 2、============开始写入class文件
|
|
|
ClassFileUtil.deleteClassfile(classPath);
|
|
@ -239,7 +237,7 @@ public class ESBCamelService {
|
|
|
/* ************************** 修改任务cron生成新的camel文件 add by hzy *********************************** */
|
|
|
public Result genNewClassfile(String type,String filePath, String packageName, String oldClassName, String newClassName,String newCron) {
|
|
|
try {
|
|
|
String path = null;
|
|
|
String path;
|
|
|
if ("route".equals(type)){
|
|
|
path = CamelCompiler.compiler(filePath,packageName,oldClassName,newClassName,newCron);
|
|
|
}else if ("processor".equals(type)){
|