package com.quartz;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * 监听策略信息
 * 获取预执行任务
 * @author dubaohui
 * */
public class queryservlet extends HttpServlet {
	private static Scheduler sched =null;
	public queryservlet() 
	{
		super();
	}
	
	public void init() throws ServletException {
//		SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
//		try {
//			sched = StdSchedulerFactory.getDefaultScheduler();
//			if(sched.isStarted()){
//				sched.shutdown(true); //如果已经启动 停止当前调度任务
//				sched = StdSchedulerFactory.getDefaultScheduler();
//			}
//			ServletContext sc = getServletContext();
//			WebApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
//		
//		JobDetail jobDetai1 = new JobDetail("订单解锁", sched.DEFAULT_GROUP,UnlockOrder.class);
//			try {
//				Trigger trigger1 =new CronTrigger("启动订单解锁扫描", Scheduler.DEFAULT_GROUP,"0 0/10 * * * ?");
//				sched.scheduleJob(jobDetai1,trigger1);
//			    sched.start();
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
//		} catch (SchedulerException e) {
//			e.printStackTrace();
//		}
		
	}
	 public void doGet(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {
//		 try {
//			  if(sched.isStarted())
//			  {
//			   sched.shutdown(true);
//			  }
//			  if(sched.isShutdown())
//				{
//				 init();
//				}
//		} catch (SchedulerException e) {
//			e.printStackTrace();
//		}

		
		
	 }
	 public void doPost(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {
//       doGet(request, response);
    }
	 
}
