package com.ema.admin.handler;

import com.ema.common.consts.CommonConst;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 系统启动监听器
 */
@Slf4j
@Component
public class SystemEventListener {

    @Resource(name = CommonConst.ASYNC_POOL)
    private ThreadPoolTaskExecutor threadPoolExecutor;

    /**
     * 监听项目启动后，初始化所有各任务
     * @param event
     */
    @EventListener(ApplicationStartedEvent.class)
    public void runListener(ApplicationStartedEvent event) {

        //初始化所有定时任务
        threadPoolExecutor.execute(() -> {
            //sysTimersJobService.initAllTimerJob();
        });

    }



}
