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