use of org.quartz.JobExecutionContext in project weicoder by wdcode.
the class ExecutingJobsManager method interrupt.
/**
* Interrupt the identified InterruptableJob executing in this Scheduler instance.
*
* <p>
* This method is not cluster aware. That is, it will only interrupt
* instances of the identified InterruptableJob currently executing in this
* Scheduler instance, not across the entire cluster.
* </p>
*
* @see org.quartz.core.RemotableQuartzScheduler#interrupt(JobKey)
*/
public boolean interrupt(String fireInstanceId) throws UnableToInterruptJobException {
List<JobExecutionContext> jobs = getCurrentlyExecutingJobs();
Job job = null;
for (JobExecutionContext jec : jobs) {
if (jec.getFireInstanceId().equals(fireInstanceId)) {
job = jec.getJobInstance();
if (job instanceof InterruptableJob) {
((InterruptableJob) job).interrupt();
return true;
} else {
throw new UnableToInterruptJobException("Job " + jec.getJobDetail().getKey() + " can not be interrupted, since it does not implement " + InterruptableJob.class.getName());
}
}
}
return false;
}
use of org.quartz.JobExecutionContext in project weicoder by wdcode.
the class JobExecutionContextSupport method toTabularData.
/**
* @return array of region statistics
*/
public static TabularData toTabularData(final List<JobExecutionContext> executingJobs) throws SchedulerException {
List<CompositeData> list = new ArrayList<CompositeData>();
for (JobExecutionContext executingJob : executingJobs) {
list.add(toCompositeData(executingJob));
}
TabularData td = new TabularDataSupport(TABULAR_TYPE);
td.putAll(list.toArray(new CompositeData[list.size()]));
return td;
}
use of org.quartz.JobExecutionContext in project smarthome by eclipse.
the class MockScheduler method run.
/**
* "Run" all of the jobs in the scheduler.
*
* NB this is a mock class. We ignore the time that the jobs are
* actually scheduled for, and just run them all.
*
* @throws JobExecutionException
* @throws IllegalAccessException
* @throws InstantiationException
*/
public void run() throws JobExecutionException, InstantiationException, IllegalAccessException {
for (Entry<Trigger, JobExecutionContext> entry : jobs.entrySet()) {
JobExecutionContext context = entry.getValue();
try {
currentlyExecutingJobs.add(context);
Job job = context.getJobDetail().getJobClass().newInstance();
job.execute(context);
} finally {
currentlyExecutingJobs.remove(context);
jobs.remove(entry.getKey());
Trigger newTrigger = rescheduledJobs.remove(context.getTrigger().getKey());
if (newTrigger != null) {
jobs.put(newTrigger, context);
}
}
}
}
Aggregations