quartz - sample Job

import org.quartz.Job;

import org.quartz.JobDataMap;

import org.quartz.JobExecutionContext;

import org.quartz.JobExecutionException;

 

/**

 * This is quartz Job which will be execute 30 seconds

 */

public class OrderCancelJob implements Job {

 

      public OrderCancelJob()

      {}

 

      public void execute(JobExecutionContext context) throws JobExecutionException

      {

            logger.info(">>> Entering OrderCancelJob() ...");

            JobDataMap dataMap = context.getJobDetail().getJobDataMap();

            String orderId = dataMap.getString("orderId");

            OrderManager orderManager = (OrderManager)dataMap.get("orderManager");

            logger.debug("OrderCancel Job will cancel order " + orderId + " now.");

            orderManager.withdrawOrder(orderId);

            logger.info("<<< Leaving OrderCancelJob().");

      }

}

你可能感兴趣的:(quartz)