当前位置: 首页>>代码示例>>Java>>正文


Java Scheduler.getCurrentlyExecutingJobs方法代码示例

本文整理汇总了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;
}
 
开发者ID:Zigin,项目名称:MonitorPlatform,代码行数:30,代码来源:JobConfigService.java

示例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;
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:22,代码来源:ScheduleJobServiceImpl.java


注:本文中的org.quartz.Scheduler.getCurrentlyExecutingJobs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。