1 2 18 19 22 package org.quartz; 23 24 import java.util.Date ; 25 import java.util.HashMap ; 26 27 import org.quartz.spi.TriggerFiredBundle; 28 29 71 public class JobExecutionContext implements java.io.Serializable { 72 73 80 81 private transient Scheduler scheduler; 82 83 private Trigger trigger; 84 85 private JobDetail jobDetail; 86 87 private JobDataMap jobDataMap; 88 89 private transient Job job; 90 91 private Calendar calendar; 92 93 private boolean recovering = false; 94 95 private int numRefires = 0; 96 97 private Date fireTime; 98 99 private Date scheduledFireTime; 100 101 private Date prevFireTime; 102 103 private Date nextFireTime; 104 105 private long jobRunTime = -1; 106 107 private Object result; 108 109 private HashMap data = new HashMap (); 110 111 118 119 124 public JobExecutionContext(Scheduler scheduler, 125 TriggerFiredBundle firedBundle, Job job) { 126 this.scheduler = scheduler; 127 this.trigger = firedBundle.getTrigger(); 128 this.calendar = firedBundle.getCalendar(); 129 this.jobDetail = firedBundle.getJobDetail(); 130 this.job = job; 131 this.recovering = firedBundle.isRecovering(); 132 this.fireTime = firedBundle.getFireTime(); 133 this.scheduledFireTime = firedBundle.getScheduledFireTime(); 134 this.prevFireTime = firedBundle.getPrevFireTime(); 135 this.nextFireTime = firedBundle.getNextFireTime(); 136 137 this.jobDataMap = new JobDataMap(); 138 this.jobDataMap.putAll(jobDetail.getJobDataMap()); 139 this.jobDataMap.putAll(trigger.getJobDataMap()); 140 } 141 142 149 150 156 public Scheduler getScheduler() { 157 return scheduler; 158 } 159 160 166 public Trigger getTrigger() { 167 return trigger; 168 } 169 170 176 public Calendar getCalendar() { 177 return calendar; 178 } 179 180 186 public boolean isRecovering() { 187 return recovering; 188 } 189 190 public void incrementRefireCount() { 191 numRefires++; 192 } 193 194 public int getRefireCount() { 195 return numRefires; 196 } 197 198 223 public JobDataMap getMergedJobDataMap() { 224 return jobDataMap; 225 } 226 227 232 public JobDetail getJobDetail() { 233 return jobDetail; 234 } 235 236 247 public Job getJobInstance() { 248 return job; 249 } 250 251 259 public Date getFireTime() { 260 return fireTime; 261 } 262 263 271 public Date getScheduledFireTime() { 272 return scheduledFireTime; 273 } 274 275 public Date getPreviousFireTime() { 276 return prevFireTime; 277 } 278 279 public Date getNextFireTime() { 280 return nextFireTime; 281 } 282 283 public String toString() { 284 return "JobExecutionContext:" + " trigger: '" 285 + getTrigger().getFullName() + " job: " 286 + getJobDetail().getFullName() + " fireTime: '" + getFireTime() 287 + " scheduledFireTime: " + getScheduledFireTime() 288 + " previousFireTime: '" + getPreviousFireTime() 289 + " nextFireTime: " + getNextFireTime() + " isRecovering: " 290 + isRecovering() + " refireCount: " + getRefireCount(); 291 } 292 293 307 public Object getResult() { 308 return result; 309 } 310 311 322 public void setResult(Object result) { 323 this.result = result; 324 } 325 326 334 public long getJobRunTime() { 335 return jobRunTime; 336 } 337 338 341 public void setJobRunTime(long jobRunTime) { 342 this.jobRunTime = jobRunTime; 343 } 344 345 356 public void put(Object key, Object value) { 357 data.put(key, value); 358 } 359 360 365 public Object get(Object key) { 366 return data.get(key); 367 } 368 } 369 | Popular Tags |