package com.eactive.eai.rms.ext.tran.epb;

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;

public class TranResultExtractJob implements Job {
	
	private static final Logger logger = Logger.getLogger(TranResultExtractJob.class);
	
	public void execute(JobExecutionContext context) throws JobExecutionException {

		ApplicationContext appContext = null;
		
		try {
			appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
		} catch (SchedulerException e1) {
			logger.error(e1);
		}
		
		if (appContext == null) {
			logger.info("[TranResultExtractJob ]appContext is null");
		}
		
		if (appContext.getBean("tranResultExtractService") == null) {
			logger.info("[TranResultExtractJob ] tranResultExtractService is null");
		}

		TranResultExtractService service = (TranResultExtractService) appContext.getBean("tranResultExtractService");

		logger.info("[TranResultExtractJob START]----------");

		try {

			service.tranResultExtract();

		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		} finally {
			logger.info("[TranResultExtractJob END]----------");
		}

	}

}
