dengzedong
3 天以前 1178da30ca701da465bf7bc1342b539b2df03c7d
提交 | 用户 | 时间
a6de49 1 package com.iailab;
H 2
c12dae 3 import com.iailab.module.model.mpk.common.MdkConstant;
D 4 import com.iailab.module.model.mpk.common.utils.DllUtils;
912a1e 5 import iail.mdk.model.common.Environment;
c12dae 6 import lombok.extern.slf4j.Slf4j;
D 7 import org.springframework.beans.factory.annotation.Value;
a6de49 8 import org.springframework.boot.CommandLineRunner;
H 9 import org.springframework.boot.SpringApplication;
10 import org.springframework.boot.autoconfigure.SpringBootApplication;
7fd198 11 import org.springframework.scheduling.annotation.EnableAsync;
a6de49 12
c12dae 13 import javax.annotation.PostConstruct;
912a1e 14 import java.io.File;
D 15 import java.io.InputStream;
7fd198 16 import java.util.Properties;
17
18 @EnableAsync
a6de49 19 @SpringBootApplication
c12dae 20 @Slf4j
a6de49 21 public class ModelServiceApplication implements CommandLineRunner {
H 22
c12dae 23     @Value("${mpk.bak-file-path}")
D 24     private String mpkBakFilePath;
25
26     @PostConstruct
27     void init() {
7fd198 28         //加载动态链接库
29         try {
30             Properties properties = new Properties();
912a1e 31             InputStream in = ModelServiceApplication.class.getClassLoader().getResourceAsStream("iailmdk.properties");
D 32             properties.load(in);
33             String mdkInitPath = properties.getProperty("mdk-init-path");
c12dae 34             log.info("mdkInitPath=" + mdkInitPath);
912a1e 35             File file = new File(mdkInitPath + File.separator + "IAIL.MDK.Mid.Windows.dll");
D 36             if (!file.exists()) {
37                 throw new RuntimeException("动态链接库IAIL.MDK.Mid.Windows.dll文件不存在," + file.getAbsolutePath());
38             }
39             System.load(file.getAbsolutePath());
40             Environment env = new Environment();
41             env.init();
7fd198 42         } catch (Exception e) {
43             e.printStackTrace();
c12dae 44             log.error("动态链接库IAIL.MDK.Mid.Windows.dll初始化失败");
7fd198 45         }
449017 46
c12dae 47         //加载项目已发布的dll和jar
D 48         try {
558ffc 49             log.info("************开始加载项目已发布的dll和jar**************");
c12dae 50             DllUtils.loadProjectPublish(mpkBakFilePath + File.separator + MdkConstant.PROJECT_PUBLISH);
558ffc 51             log.info("************加载项目已发布的dll和jar结束**************");
c12dae 52         } catch (Exception e) {
D 53             e.printStackTrace();
54             log.error("加载项目已发布的dll和jar失败");
55         }
7fd198 56     }
137356 57
a6de49 58
H 59     public static void main(String[] args) {
60         SpringApplication.run(ModelServiceApplication.class, args);
61     }
62
63     /**
64      * 容器初始化后加载路由
65      *
66      * @param strings
67      */
68     @Override
69     public void run(String... strings) {
70     }
71 }