本文整理匯總了Java中org.quartz.JobKey.getGroup方法的典型用法代碼示例。如果您正苦於以下問題:Java JobKey.getGroup方法的具體用法?Java JobKey.getGroup怎麽用?Java JobKey.getGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.quartz.JobKey
的用法示例。
在下文中一共展示了JobKey.getGroup方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getJobGroupNames
import org.quartz.JobKey; //導入方法依賴的package包/類
/**
* @Title: getJobGroupNames
* @Description: TODO(獲取調度器所有任務計劃)
* @author [email protected] (苟誌強)
* @date 2017-9-26 下午5:27:46
*/
@SuppressWarnings("unchecked")
public JSONArray getJobGroupNames(){
if(scheduler==null){
init();
}
JSONArray array = new JSONArray();
try {
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);
String nextFireTime = TimeUtil.String(triggers.get(0).getNextFireTime(), TimeUtil.DATE_TIME);
System.out.println("[分組名稱]:"+jobGroup+"[任務名稱]:"+jobName+"[下一次執行時間]:"+nextFireTime);
JSONObject json = new JSONObject();
json.put("name", jobName);
json.put("group", jobGroup);
json.put("nextFireTime", nextFireTime);
array.add(json);
}
}
} catch (Exception e) {
}
return array;
}
示例2: getAllJobs
import org.quartz.JobKey; //導入方法依賴的package包/類
/**
* Get all jobs
*/
@Override
public List<Map<String, Object>> getAllJobs() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
try {
Scheduler scheduler = schedulerFactoryBean.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 scheduleTime = triggers.get(0).getStartTime();
Date nextFireTime = triggers.get(0).getNextFireTime();
Date lastFiredTime = triggers.get(0).getPreviousFireTime();
Map<String, Object> map = new HashMap<String, Object>();
map.put("jobName", jobName);
map.put("groupName", jobGroup);
map.put("scheduleTime", scheduleTime);
map.put("lastFiredTime", lastFiredTime);
map.put("nextFireTime", nextFireTime);
if(isJobRunning(jobName)){
map.put("jobStatus", "RUNNING");
}else{
String jobState = getJobState(jobName);
map.put("jobStatus", jobState);
}
/* Date currentDate = new Date();
if (scheduleTime.compareTo(currentDate) > 0) {
map.put("jobStatus", "scheduled");
} else if (scheduleTime.compareTo(currentDate) < 0) {
map.put("jobStatus", "Running");
} else if (scheduleTime.compareTo(currentDate) == 0) {
map.put("jobStatus", "Running");
}*/
list.add(map);
System.out.println("Job details:");
System.out.println("Job Name:"+jobName + ", Group Name:"+ groupName + ", Schedule Time:"+scheduleTime);
}
}
} catch (SchedulerException e) {
System.out.println("SchedulerException while fetching all jobs. error message :"+e.getMessage());
e.printStackTrace();
}
return list;
}