package com.eactive.eai.rms.onl.common.service;

import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.springframework.context.ApplicationContext;

import com.eactive.eai.rms.onl.server.repository.AdaptersStatusRepository;

public class AdaptersStatusSendInitJob implements Job{
    /**
    * Logger for this class
    */
    private static final Logger logger = Logger.getLogger(AdaptersStatusSendInitJob.class);

    private AdaptersStatusRepository adapterStatusRepository;
    

    //@ScheduleMethod(type = ScheduleType.CRON, cronExpression = "0 0 * * * ?")
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
       // JobKey jobKey = context.getJobDetail().getKey();

		ApplicationContext appContext = null;
		try {
			appContext = (ApplicationContext)context.getScheduler().getContext().get("applicationContext");
		} catch (SchedulerException e) {
			logger.error("applicationContext get module error",e);
			return ;
		}  
		adapterStatusRepository = (AdaptersStatusRepository)appContext.getBean("adaptersStatusRepository");			
		
    	
		if (logger.isInfoEnabled()){
			logger.info("Adapters Status Send cleanup start ");
		}
		adapterStatusRepository.cleanupSendRepository();

		if (logger.isInfoEnabled()){
			logger.info("Adapters Status Send cleanup end");
		}		
		
	}


}
