wuxw
2019-11-21 59ce81c19b75e3e6cdc6a3a65d49ec11e27b0a06
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
package com.java110.front.listener;
 
import com.java110.config.properties.code.Java110Properties;
import com.java110.utils.factory.ApplicationContextFactory;
 
/**
 * 只用于开发时组件 自动加载,无需自动启动服务去加载组件
 * 可能会影响性能
 * add by wuxw 2019-11-21
 */
public class ReloadComponentFileListenerFactory {
 
    public static void startReloadComponentFileListener() {
        Java110Properties java110Properties = ApplicationContextFactory.getBean("java110Properties", Java110Properties.class);
        boolean autoReloadComponent = java110Properties.getAutoReloadComponent();
        //如果不是开发环境则不启用 自动加载组件功能
        if (!"dev".equals(ApplicationContextFactory.getActiveProfile())) {
            autoReloadComponent = false;
        }
        ReloadComponentFileListener reloadComponentFileListener = new ReloadComponentFileListener(autoReloadComponent);
        Thread componentThread = new Thread(reloadComponentFileListener, "thread-ReloadComponentFileListener");
        componentThread.start();
    }
 
}