當前位置: 首頁>>代碼示例>>Java>>正文


Java JobKey.getGroup方法代碼示例

本文整理匯總了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;
}
 
開發者ID:zhiqiang94,項目名稱:BasicsProject,代碼行數:33,代碼來源:QuartzUtil.java

示例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;
}
 
開發者ID:javabypatel,項目名稱:spring-boot-quartz-demo,代碼行數:59,代碼來源:JobServiceImpl.java


注:本文中的org.quartz.JobKey.getGroup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。