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


Java Scheduler.getJobGroupNames方法代码示例

本文整理汇总了Java中org.quartz.Scheduler.getJobGroupNames方法的典型用法代码示例。如果您正苦于以下问题:Java Scheduler.getJobGroupNames方法的具体用法?Java Scheduler.getJobGroupNames怎么用?Java Scheduler.getJobGroupNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.Scheduler的用法示例。


在下文中一共展示了Scheduler.getJobGroupNames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllJobsOfScheduler

import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
 * 获取scheduler下所有的jobDetail
 * @param scheduler
 * @return
 * @throws SchedulerException
 */
public static List<JobDetail> getAllJobsOfScheduler(Scheduler scheduler) throws SchedulerException {
    List<JobDetail> result = new ArrayList<JobDetail>();
    List<String> jobGroupNames = scheduler.getJobGroupNames();
    for (String groupName : jobGroupNames) {
        Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.<JobKey>groupEquals(groupName));
        for (JobKey jobKey : jobKeys) {
            JobDetail jobDetail = scheduler.getJobDetail(jobKey);
            result.add(jobDetail);
        }
    }
    return result;
}
 
开发者ID:quartzweb,项目名称:quartz-web,代码行数:19,代码来源:QuartzUtils.java

示例2: doHandleRequest

import org.quartz.Scheduler; //导入方法依赖的package包/类
@Override
protected ModelAndView doHandleRequest(HttpServletRequest req,HttpServletResponse res) throws Exception {
	SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	Scheduler scheduler=instanceDetection.getScheduler();
	StringBuffer sb=new StringBuffer();
	sb.append("<strong>Status</strong>:");
	if(scheduler.isInStandbyMode()){
		sb.append("Standby");
	}
	if(scheduler.isShutdown()){
		sb.append("Shutdown");
	}
	if(scheduler.isStarted()){
		sb.append("Started");
	}
	sb.append("<br>");
	for (String groupName : scheduler.getJobGroupNames()) {
	     for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
	    	 JobDetail jobDetail=scheduler.getJobDetail(jobKey);
	    	 sb.append("<strong>JobClass:</strong>");
	    	 sb.append(jobDetail.getJobClass().getName());
	    	 
	    	 Trigger trigger=scheduler.getTriggersOfJob(jobDetail.getKey()).get(0);
	    	 sb.append("<br><strong>PreviousFireDate:</strong>");
	    	 if(trigger.getPreviousFireTime()!=null){
	    		 sb.append(sd.format(trigger.getPreviousFireTime()));		    		 
	    	 }
	    	 sb.append("<br><strong>NextFireDate:</strong>");
	    	 if(sd.format(trigger.getNextFireTime())!=null){
	    		 sb.append(sd.format(trigger.getNextFireTime()));		    		 
	    	 }
	    	 if(trigger instanceof CronTriggerImpl){
	    		 CronTriggerImpl cron=(CronTriggerImpl)trigger;
	    		 sb.append("<br><strong>CronExpression:</strong>");
	    		 sb.append(cron.getCronExpression());
	    	 }
	    	 
	     }
	}
	res.setContentType("text/html; charset=utf-8");
	PrintWriter pw=res.getWriter();
	pw.write(sb.toString());
	pw.flush();
	pw.close();
	return null;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:47,代码来源:DaemonStatusController.java

示例3: getAllJobs

import org.quartz.Scheduler; //导入方法依赖的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

示例4: loadScheduerInfo

import org.quartz.Scheduler; //导入方法依赖的package包/类
@DataProvider
public SchedulerInfo loadScheduerInfo() throws Exception{
	SchedulerInfo info=new SchedulerInfo();
	info.setRunJob(schedulerService.isRunJobInCurrentInstance());
	Scheduler scheduler=schedulerService.getCurrentScheduler();
	if(scheduler!=null){
		if(scheduler.isStarted()){
			info.setState(SchedulerState.started);
		}else if(scheduler.isShutdown()){
			info.setState(SchedulerState.shutdown);
		}else if(scheduler.isInStandbyMode()){
			info.setState(SchedulerState.standby);
		}
		info.setJobInstanceName(schedulerService.getJobInstanceName());
		List<JobInfo> jobs=new ArrayList<JobInfo>();
		for (String groupName : scheduler.getJobGroupNames()) {
			for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
				JobInfo jobInfo=new JobInfo();
				JobDetail jobDetail=scheduler.getJobDetail(jobKey);
				if(jobDetail instanceof SpringBeanJobExecutorDetail){
					SpringBeanJobExecutorDetail springBeanDetail=(SpringBeanJobExecutorDetail)jobDetail;
					jobInfo.setTargetJobInfo("SpringBean:"+springBeanDetail.getTargetJobBeanId());
					jobInfo.setType(JobType.definition);
					
				}else if(jobDetail instanceof ScanJobExecutorDetail){
					jobInfo.setType(JobType.scan);
					jobInfo.setTargetJobInfo(jobDetail.getJobClass().getName());
				}
				Trigger trigger=scheduler.getTriggersOfJob(jobKey).get(0);
				jobInfo.setName(jobDetail.getKey().getName());
				jobInfo.setGroup(jobDetail.getKey().getGroup());
				jobInfo.setNextFireDate(trigger.getNextFireTime());
				jobInfo.setPreviousFireDate(trigger.getPreviousFireTime());
				if(trigger instanceof CronTriggerImpl){
					CronTriggerImpl cron=(CronTriggerImpl)trigger;
					jobInfo.setTriggerInfo("Cron表达式类型触发器["+cron.getCronExpression()+"]");
				}else{
					jobInfo.setTriggerInfo("触发器类型:"+trigger.getClass());
				}
				jobs.add(jobInfo);
				
			}
			info.setJobs(jobs);
		}
	}
	return info;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:48,代码来源:SchedulerAnalysis.java


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