本文整理汇总了Java中org.quartz.Scheduler.getCurrentlyExecutingJobs方法的典型用法代码示例。如果您正苦于以下问题:Java Scheduler.getCurrentlyExecutingJobs方法的具体用法?Java Scheduler.getCurrentlyExecutingJobs怎么用?Java Scheduler.getCurrentlyExecutingJobs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.Scheduler
的用法示例。
在下文中一共展示了Scheduler.getCurrentlyExecutingJobs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRunningJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 所有正在运行的job
*
* @return
* @throws SchedulerException
*/
public List<ScheduleJob> getRunningJob() throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
List<ScheduleJob> jobList = new ArrayList<ScheduleJob>(executingJobs.size());
for (JobExecutionContext executingJob : executingJobs) {
ScheduleJob job = new ScheduleJob();
JobDetail jobDetail = executingJob.getJobDetail();
JobKey jobKey = jobDetail.getKey();
Trigger trigger = executingJob.getTrigger();
job.setName(jobKey.getName());
job.setGroup(jobKey.getGroup());
job.setDescription("触发器:" + trigger.getKey());
Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
job.setStatus(triggerState.name());
if (trigger instanceof CronTrigger) {
CronTrigger cronTrigger = (CronTrigger) trigger;
String cronExpression = cronTrigger.getCronExpression();
job.setCron(cronExpression);
}
jobList.add(job);
}
return jobList;
}
示例2: getRunningJobList
import org.quartz.Scheduler; //导入方法依赖的package包/类
@Override
public List<ScheduleJobEntity> getRunningJobList() {
List<ScheduleJobEntity> jobList = null;
Scheduler scheduler = schedulerFactoryBean.getScheduler();
try {
List<JobExecutionContext> executingJobList = scheduler.getCurrentlyExecutingJobs();
jobList = new ArrayList<>(executingJobList.size());
for (JobExecutionContext executingJob : executingJobList) {
ScheduleJobEntity scheduleJob = new ScheduleJobEntity();
JobDetail jobDetail = executingJob.getJobDetail();
JobKey jobKey = jobDetail.getKey();
Trigger trigger = executingJob.getTrigger();
this.wrapScheduleJob(scheduleJob, scheduler, jobKey, trigger);
jobList.add(scheduleJob);
}
} catch (Exception e) {
logger.error("获取计划任务列表失败", e);
throw new ServiceException("获取计划任务列表失败", e);
}
return jobList;
}