1 17 18 package org.quartz.examples.example5; 19 20 import java.util.Date ; 21 22 import org.apache.commons.logging.Log; 23 import org.apache.commons.logging.LogFactory; 24 import org.quartz.StatefulJob; 25 import org.quartz.JobDataMap; 26 import org.quartz.JobExecutionContext; 27 import org.quartz.JobExecutionException; 28 29 36 public class MisfireJob implements StatefulJob { 37 38 private static Log _log = LogFactory.getLog(MisfireJob.class); 40 41 public static final String NUM_EXECUTIONS = "NumExecutions"; 43 public static final String EXECUTION_DELAY = "ExecutionDelay"; 44 45 48 public MisfireJob() { 49 } 50 51 60 public void execute(JobExecutionContext context) 61 throws JobExecutionException { 62 String jobName = context.getJobDetail().getFullName(); 63 _log.info("---" + jobName + " executing at " + new Date ()); 64 65 long delay = 5000L; 67 68 JobDataMap map = context.getJobDetail().getJobDataMap(); 70 if (map.containsKey(EXECUTION_DELAY)) { 71 delay = map.getLong(EXECUTION_DELAY); 72 } 73 74 try { 75 Thread.sleep(delay); 76 } catch (Exception ignore) { 77 } 78 79 _log.info("---" + jobName + " completed at " + new Date ()); 80 } 81 82 } | Popular Tags |