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


Java CronTrigger.getCronExpression方法代碼示例

本文整理匯總了Java中org.quartz.CronTrigger.getCronExpression方法的典型用法代碼示例。如果您正苦於以下問題:Java CronTrigger.getCronExpression方法的具體用法?Java CronTrigger.getCronExpression怎麽用?Java CronTrigger.getCronExpression使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.CronTrigger的用法示例。


在下文中一共展示了CronTrigger.getCronExpression方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRunningJob

import org.quartz.CronTrigger; //導入方法依賴的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: getAllJob

import org.quartz.CronTrigger; //導入方法依賴的package包/類
/**
 * 獲取所有計劃中的任務列表
 * 
 * @return
 * @throws SchedulerException
 */
public List<ScheduleJob> getAllJob() throws SchedulerException {
    Scheduler scheduler = schedulerFactoryBean.getScheduler();
    GroupMatcher<JobKey> matcher = GroupMatcher.anyJobGroup();
    Set<JobKey> jobKeys = scheduler.getJobKeys(matcher);
    List<ScheduleJob> jobList = new ArrayList<ScheduleJob>();
    for (JobKey jobKey : jobKeys) {
        List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
        for (Trigger trigger : triggers) {
            ScheduleJob job = new ScheduleJob();
            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,代碼行數:31,代碼來源:JobConfigService.java

示例3: modifyJobTime

import org.quartz.CronTrigger; //導入方法依賴的package包/類
/** 
 * @Description: 修改一個任務的觸發時間(使用默認的任務組名,觸發器名,觸發器組名)  
 * @param jobName 
 * @param time 
 *  
 */  
@SuppressWarnings("unchecked")    
public static void modifyJobTime(String jobName, String time) {   
    TriggerKey triggerKey = TriggerKey.triggerKey(  
            jobName, TRIGGER_GROUP_NAME);  
      
    try {    
        Scheduler sched = gSchedulerFactory.getScheduler();    
        CronTrigger trigger =(CronTrigger) sched.getTrigger(triggerKey);  
        if (trigger == null) {    
            return;    
        }    
        String oldTime = trigger.getCronExpression();    
        if (!oldTime.equalsIgnoreCase(time)) {  
            CronScheduleBuilder scheduleBuilder =CronScheduleBuilder.cronSchedule(time);  
            //按新的cronExpression表達式重新構建trigger  
            trigger = trigger.getTriggerBuilder().withIdentity(triggerKey)  
            .withSchedule(scheduleBuilder).build();  
            //按新的trigger重新設置job執行  
            sched.rescheduleJob(triggerKey, trigger);  
        }    
    } catch (Exception e) {    
        throw new RuntimeException(e);    
    }    
}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:31,代碼來源:MicroQuartzManager.java

示例4: wrapScheduleJob

import org.quartz.CronTrigger; //導入方法依賴的package包/類
private void wrapScheduleJob(ScheduleJob scheduleJob,Scheduler scheduler,JobKey jobKey,Trigger trigger){  
    try {  
        scheduleJob.setJobName(jobKey.getName());  
        scheduleJob.setJobGroup(jobKey.getGroup()); 
  
        JobDetail jobDetail = scheduler.getJobDetail(jobKey);  
        ScheduleJob job = (ScheduleJob)jobDetail.getJobDataMap().get("scheduleJob");  
        scheduleJob.setDesc(job.getDesc());  
        scheduleJob.setJobId(job.getJobId());
  
        Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());  
        scheduleJob.setJobStatus(triggerState.name());  
        if(trigger instanceof CronTrigger){  
            CronTrigger cronTrigger = (CronTrigger)trigger;  
            String cronExpression = cronTrigger.getCronExpression();  
            scheduleJob.setCronExpression(cronExpression);  
        }  
    } catch (SchedulerException e) {  
        e.printStackTrace(); 
    }  
}
 
開發者ID:jiwenxing,項目名稱:springboot-quartz,代碼行數:22,代碼來源:ScheduleJobService.java

示例5: toCompositeData

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public static CompositeData toCompositeData(CronTrigger trigger) {
    try {
        return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
                new Object[] {
                        trigger.getCronExpression(),
                        trigger.getTimeZone(),
                        trigger.getKey().getName(),
                        trigger.getKey().getGroup(),
                        trigger.getJobKey().getName(),
                        trigger.getJobKey().getGroup(),
                        trigger.getDescription(),
                        JobDataMapSupport.toTabularData(trigger
                                .getJobDataMap()),
                        trigger.getCalendarName(),
                        ((OperableTrigger)trigger).getFireInstanceId(),
                        trigger.getMisfireInstruction(),
                        trigger.getPriority(), trigger.getStartTime(),
                        trigger.getEndTime(), trigger.getNextFireTime(),
                        trigger.getPreviousFireTime(),
                        trigger.getFinalFireTime() });
    } catch (OpenDataException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:CronTriggerSupport.java

示例6: getRunningJobs

import org.quartz.CronTrigger; //導入方法依賴的package包/類
/**
 * 獲取運行中的任務
 */
public List<ScheduleJob> getRunningJobs() 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.setJobId(jobKey.getGroup() + "_" + jobKey.getName());
        job.setJobName(jobKey.getName());
        job.setJobGroup(jobKey.getGroup());
        job.setDesc(trigger.getDescription());
        Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
        job.setJobStatus(triggerState.name());
        if (trigger instanceof CronTrigger) {
            CronTrigger cronTrigger = (CronTrigger) trigger;
            String cronExpression = cronTrigger.getCronExpression();
            job.setCronExpression(cronExpression);
        }
        jobList.add(job);
    }
    return jobList;
}
 
開發者ID:bill1012,項目名稱:AdminEAP,代碼行數:28,代碼來源:JobServiceImpl.java

示例7: modifyJobTime

import org.quartz.CronTrigger; //導入方法依賴的package包/類
/**
 * 修改一個任務的觸發時間(使用默認的任務組名,觸發器名,觸發器組名)
 *
 * @param jobName
 * @param time
 */
public static void modifyJobTime(String jobName, String time) {
	try {
		Scheduler sched = gSchedulerFactory.getScheduler();
		CronTrigger trigger = (CronTrigger) sched.getTrigger(jobName, TRIGGER_GROUP_NAME);
		if(trigger == null) {
			return;
		}
		String oldTime = trigger.getCronExpression();
		if (!oldTime.equalsIgnoreCase(time)) {
			JobDetail jobDetail = sched.getJobDetail(jobName, JOB_GROUP_NAME);
			Class objJobClass = jobDetail.getJobClass();
			String jobClass = objJobClass.getName();
			removeJob(jobName);

			addJob(jobName, jobClass, time);
		}
	} catch (Exception e) {
		e.printStackTrace();
		throw new RuntimeException(e);
	}
}
 
開發者ID:yancykim,項目名稱:support,代碼行數:28,代碼來源:QuartzManager.java

示例8: getPlanification

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public static String getPlanification(Trigger trigger) {
    if (trigger instanceof CronTrigger) {
        CronTrigger cronTrigger = (CronTrigger) trigger;

        try {
            return CronExpressionDescriptor.getDescription(cronTrigger.getCronExpression())
                    + "<br/>(" + cronTrigger.getCronExpression() + ")";
        } catch (ParseException e) {
            return cronTrigger.getCronExpression();
        }
    }

    SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;

    return getPlanification(simpleTrigger.getRepeatCount(), simpleTrigger.getRepeatInterval());
}
 
開發者ID:bingoohuang,項目名稱:quartz-glass,代碼行數:17,代碼來源:TriggerUtils.java

示例9: getAllJobDetail

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public List<TaskScheduled> getAllJobDetail() {
    List<TaskScheduled> result = new LinkedList<TaskScheduled>();
    try {
        GroupMatcher<JobKey> matcher = GroupMatcher.jobGroupContains("");
        Set<JobKey> jobKeys = scheduler.getJobKeys(matcher);
        for (JobKey jobKey : jobKeys) {
            JobDetail jobDetail = scheduler.getJobDetail(jobKey);
            List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
            for (Trigger trigger : triggers) {
                TaskScheduled job = new TaskScheduled();
                job.setTaskName(jobKey.getName());
                job.setTaskGroup(jobKey.getGroup());
                TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
                job.setStatus(triggerState.name());
                if (trigger instanceof CronTrigger) {
                    CronTrigger cronTrigger = (CronTrigger)trigger;
                    String cronExpression = cronTrigger.getCronExpression();
                    job.setTaskCron(cronExpression);
                }
                job.setPreviousFireTime(trigger.getPreviousFireTime());
                job.setNextFireTime(trigger.getNextFireTime());
                JobDataMap jobDataMap = trigger.getJobDataMap();
                job.setTaskType(jobDataMap.getString("taskType"));
                job.setTargetSystem(jobDataMap.getString("targetSystem"));
                job.setTargetObject(jobDataMap.getString("targetObject"));
                job.setTargetMethod(jobDataMap.getString("targetMethod"));
                job.setContactName(jobDataMap.getString("contactName"));
                job.setContactEmail(jobDataMap.getString("contactEmail"));
                job.setTaskDesc(jobDetail.getDescription());
                String jobClass = jobDetail.getJobClass().getSimpleName();
                if (jobClass.equals("StatefulJob")) {
                    job.setJobType("statefulJob");
                } else if (jobClass.equals("DefaultJob")) {
                    job.setJobType("job");
                }
                result.add(job);
            }
        }
    } catch (Exception e) {
        logger.error("Try to load All JobDetail cause error : ", e);
    }
    return result;
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:44,代碼來源:SchedulerManager.java

示例10: getCronJob

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public ScheduleJob getCronJob(ScheduleJob job, Trigger trigger) {
    CronTrigger cronTrigger = (CronTrigger) trigger;
    String cronExpression = cronTrigger.getCronExpression();
    job.setCronExpression(cronExpression);
    job.setTriggerType("CronTrigger");
    job.setStartTime(cronTrigger.getStartTime());
    job.setEndTime(cronTrigger.getEndTime());
    job.setTriggerName(cronTrigger.getKey().getName());
    job.setTriggerGroup(cronTrigger.getKey().getGroup());
    return job;
}
 
開發者ID:bill1012,項目名稱:AdminEAP,代碼行數:12,代碼來源:JobServiceImpl.java

示例11: queryList

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public List<ScheduleJobBo> queryList(ScheduleJobBo scheduleJobBo) {

		// List<ScheduleJob> scheduleJobs = jdbcDao.queryList(scheduleJobBo
		// .getTargetObject(ScheduleJob.class));
		// List<ScheduleJob> scheduleJobs = new ArrayList<ScheduleJob>();

		// List<scheduleJobBo> scheduleJobBoList =
		// BeanConverter.convert(scheduleJobBo.class,scheduleJobs);
		List<ScheduleJobBo> scheduleJobBoList = new ArrayList<ScheduleJobBo>();
		try {
			for (ScheduleJobBo vo : scheduleJobBoList) {

				JobKey jobKey = ScheduleJobUtils.getJobKey(vo.getJobName(), vo.getJobGroup());
				List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
				if (CollectionUtils.isEmpty(triggers)) {
					continue;
				}

				// 這裏一個任務可以有多個觸發器, 但是我們一個任務對應一個觸發器,所以隻取第一個即可,清晰明了
				Trigger trigger = triggers.iterator().next();
				scheduleJobBo.setJobTrigger(trigger.getKey().getName());

				Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
				vo.setStatus(triggerState.name());

				if (trigger instanceof CronTrigger) {
					CronTrigger cronTrigger = (CronTrigger) trigger;
					String cronExpression = cronTrigger.getCronExpression();
					vo.setCronExpression(cronExpression);
				}
			}
		} catch (SchedulerException e) {
			// 演示用,就不處理了
		}
		return scheduleJobBoList;
	}
 
開發者ID:amao12580,項目名稱:RSSReader,代碼行數:37,代碼來源:ScheduleJobBizImpl.java

示例12: queryExecutingJobList

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public List<ScheduleJobBo> queryExecutingJobList() {
	try {
		List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
		List<ScheduleJobBo> jobList = new ArrayList<ScheduleJobBo>(executingJobs.size());
		for (JobExecutionContext executingJob : executingJobs) {
			ScheduleJobBo job = new ScheduleJobBo();
			JobDetail jobDetail = executingJob.getJobDetail();
			JobKey jobKey = jobDetail.getKey();
			Trigger trigger = executingJob.getTrigger();
			job.setJobName(jobKey.getName());
			job.setJobGroup(jobKey.getGroup());
			job.setJobTrigger(trigger.getKey().getName());
			Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
			job.setStatus(triggerState.name());
			if (trigger instanceof CronTrigger) {
				CronTrigger cronTrigger = (CronTrigger) trigger;
				String cronExpression = cronTrigger.getCronExpression();
				job.setCronExpression(cronExpression);
			}
			jobList.add(job);
		}
		return jobList;
	} catch (SchedulerException e) {
		// 演示用,就不處理了
		return null;
	}

}
 
開發者ID:amao12580,項目名稱:RSSReader,代碼行數:29,代碼來源:ScheduleJobBizImpl.java

示例13: getJobInfo

import org.quartz.CronTrigger; //導入方法依賴的package包/類
private String getJobInfo(Trigger trigger, String jobType) throws SchedulerException {
    if (jobType.equals(JobBasicInfo.JOBTYPE_REPEATING)) {
        Integer timesTriggered = 0;
        String repeatMaxCount = "-";

        if (trigger instanceof CalendarIntervalTrigger) {
            CalendarIntervalTrigger calendarIntervalTrigger = (CalendarIntervalTrigger) trigger;

            timesTriggered = calendarIntervalTrigger.getTimesTriggered();
        } else if (trigger instanceof SimpleTrigger) {
            SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;

            timesTriggered = simpleTrigger.getTimesTriggered();
        }

        if (trigger.getEndTime() != null) {
            repeatMaxCount = Integer.toString(TriggerUtils.computeFireTimesBetween(
                    (OperableTrigger) trigger, null, trigger.getStartTime(), trigger.getEndTime()
            ).size() + timesTriggered);
        }

        return String.format("%d/%s", timesTriggered, repeatMaxCount);
    } else if (jobType.equals(JobBasicInfo.JOBTYPE_CRON)) {
        CronScheduleBuilder cronScheduleBuilder = (CronScheduleBuilder) trigger.getScheduleBuilder();

        CronTrigger cronTrigger = (CronTrigger) cronScheduleBuilder.build();

        return cronTrigger.getCronExpression();
    } else {
        return "-";
    }
}
 
開發者ID:motech,項目名稱:motech,代碼行數:33,代碼來源:MotechSchedulerDatabaseServiceImpl.java

示例14: buildDayOfWeekSchedulableJob

import org.quartz.CronTrigger; //導入方法依賴的package包/類
private static SchedulableJob buildDayOfWeekSchedulableJob(Trigger trigger, JobDataMap dataMap) {
    CronTrigger cronTrigger = (CronTrigger) trigger;
    DayOfWeekSchedulableJob job = new DayOfWeekSchedulableJob();
    job.setEndDate(getEndDate(trigger));
    job.setIgnorePastFiresAtStart(dataMap.getBoolean(IGNORE_PAST_FIRES_AT_START));

    CronExpressionUtil cronExpressionUtil = new CronExpressionUtil(cronTrigger.getCronExpression());
    job.setTime(cronExpressionUtil.getTime());
    job.setDays(cronExpressionUtil.getDaysOfWeek());

    return job;
}
 
開發者ID:motech,項目名稱:motech,代碼行數:13,代碼來源:SchedulableJobBuilder.java

示例15: getRunningJob

import org.quartz.CronTrigger; //導入方法依賴的package包/類
/**
 * 獲取正在運行的job
 * 
 * @return
 * @throws SchedulerException
 */
public List<ScheduleJob> getRunningJob() throws SchedulerException {
	// Scheduler scheduler = (Scheduler) ac.getBean("schedulerFactoryBean");
	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.setJobName(jobKey.getName());
		job.setJobGroup(jobKey.getGroup());
		job.setDescription("觸發器:" + trigger.getKey());
		Trigger.TriggerState triggerState = scheduler
				.getTriggerState(trigger.getKey());
		job.setJobStatus(triggerState.name());
		if (trigger instanceof CronTrigger) {
			CronTrigger cronTrigger = (CronTrigger) trigger;
			String cronExpression = cronTrigger.getCronExpression();
			job.setCronExpression(cronExpression);
		}
		jobList.add(job);
	}
	return jobList;
}
 
開發者ID:dachuanz,項目名稱:quartz,代碼行數:33,代碼來源:QuartzUtils.java


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