dengzedong
2024-10-10 a8f2f4e6f1a9173d7eb9779c7879674015c8cda0
项目启动加载已发布的dll和jar 先判断文件是否存在
已修改1个文件
11 ■■■■■ 文件已修改
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/DllUtils.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/DllUtils.java
@@ -1,5 +1,6 @@
package com.iailab.module.model.mpk.common.utils;
import cn.hutool.core.io.FileUtil;
import com.iailab.module.model.mpk.common.MdkConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -181,23 +182,25 @@
                        String jarFilePath = bakPath + File.separator + projectId + MdkConstant.SPLIT + historyId + ".jar";
                        String dllFilePath = bakPath + File.separator + projectId + MdkConstant.SPLIT + historyId + ".dll";
                        if (FileUtil.exist(jarFilePath) && FileUtil.exist(dllFilePath)) {
                        URLClassLoader urlClassLoader = null;
                        try {
                            // 加载新的jar
                            urlClassLoader = DllUtils.loadJar(jarFilePath);
                                urlClassLoader = loadJar(jarFilePath);
                        } catch (Exception e) {
                            throw new RuntimeException("加载jar异常",e);
                        }
                        try {
                            // 加载新的dll
                            DllUtils.loadDll(urlClassLoader.loadClass("iail.mdk.model.common.Environment"),dllFilePath);
                                loadDll(urlClassLoader.loadClass("iail.mdk.model.common.Environment"),dllFilePath);
                        } catch (Exception e) {
                            DllUtils.unloadJar(urlClassLoader);
                                unloadJar(urlClassLoader);
                            throw new RuntimeException("加载dll异常",e);
                        }
                        // 都加载成功后加入缓存
                        DllUtils.addClassLoaderCache(projectId,urlClassLoader);
                            addClassLoaderCache(projectId,urlClassLoader);
                        }
                    }
                }
            }