在线二区人妖系列_国产亚洲欧美日韩在线一区_国产一级婬片视频免费看_精品少妇一区二区三区在线

鍍金池/ 教程/ Java/ Quartz列出調(diào)度器所有作業(yè)
Quartz教程
Quartz2作業(yè)監(jiān)聽
Quartz特點(diǎn)
Quartz執(zhí)行多作業(yè)
Quartz2第一個程序
Quartz列出調(diào)度器所有作業(yè)

Quartz列出調(diào)度器所有作業(yè)

下面是兩個代碼片段展示如何列出所有Quartz的作業(yè)。Quartz2 API都發(fā)生了很大變化,所以語法和Quartz1.x是不同的

1. Quartz 2.2.1 示例

Scheduler scheduler = new StdSchedulerFactory().getScheduler();
 
   for (String groupName : scheduler.getJobGroupNames()) {
 
     for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
 
	  String jobName = jobKey.getName();
	  String jobGroup = jobKey.getGroup();
 
	  //get job's trigger
	  List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey);
	  Date nextFireTime = triggers.get(0).getNextFireTime(); 
 
		System.out.println("[jobName] : " + jobName + " [groupName] : "
			+ jobGroup + " - " + nextFireTime);
 
	  }
 
    }

2. Quartz 1.8.6 示例

    Scheduler scheduler = new StdSchedulerFactory().getScheduler();
 
    //loop all group
    for (String groupName : scheduler.getJobGroupNames()) {
 
	//loop all jobs by groupname
	for (String jobName : scheduler.getJobNames(groupName)) {
 
          //get job's trigger
	  Trigger[] triggers = scheduler.getTriggersOfJob(jobName,groupName);
	  Date nextFireTime = triggers[0].getNextFireTime();
 
	  System.out.println("[jobName] : " + jobName + " [groupName] : "
			+ groupName + " - " + nextFireTime);
 
	}
 
    }