package com.nms.server.thread.email;

import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

import com.nms.server.common.Common;
import com.nms.server.common.Constants;
import com.nms.server.dao.CommonDao;
import com.nms.server.service.CommonService;
import com.nms.server.util.BoneCPPool;
import com.nms.server.util.ExceptionPrintUtils;

//监测数据主动收集管理线程
public class RefreshEmailFlagThread implements Runnable{
	private Logger logger = Logger.getLogger(RefreshEmailFlagThread.class);
	
	public void run() {
//		Thread.currentThread().setName("更新邮件功能是否启用标识 线程");
		Thread.currentThread().setName("Updata The Mail Function To Enable Identity Thread ");
		CommonDao dao = null;
		try {
			dao = new CommonDao();
			CommonService service = new CommonService(dao);
			Constants.flag_email = service.getFlagEmail();//定时的更新邮件发送是否启动标识
			
		} catch (Exception e) {
			logger.error(ExceptionPrintUtils.printExceptionStack(e));
		} finally{
			if(dao!=null){
				dao.close();
				dao=null;
			}
			logger.debug("执行结束");
		}
	}
	
	public static void main(String[] args) {
		try
		{
			BoneCPPool.initPool();
			Common.scheduled.scheduleWithFixedDelay(new RefreshEmailFlagThread(), 0, 5, TimeUnit.MINUTES);
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
