当前位置: 首页>>代码示例>>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;未经允许,请勿转载。