本文整理匯總了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;
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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 "-";
}
}
示例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;
}
示例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;
}