package com.gyee.alarm;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ApplicationReadyEventListener implements
        ApplicationListener<ApplicationReadyEvent> {

    @Autowired
    private CalculateServer calculateServer;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        System.out.println("ApplicationReadyEvent start!");
        System.out.println("listener: " + event.toString());
        try {
            calculateServer.start();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }



//    /**
//     * 重启读取报警信息
//     */
//    @Scheduled(cron = "0 0/16 * * * ?")
//    //或直接指定时间间隔，例如：5秒
//    //@Scheduled(fixedRate=5000)
//
//    private void saveFaultrecord() {
//
//        try {
//            calculateServer.stop();
//            calculateServer.start();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
}