本文整理汇总了Java中org.quartz.SimpleScheduleBuilder.withIntervalInSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleScheduleBuilder.withIntervalInSeconds方法的具体用法?Java SimpleScheduleBuilder.withIntervalInSeconds怎么用?Java SimpleScheduleBuilder.withIntervalInSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.SimpleScheduleBuilder
的用法示例。
在下文中一共展示了SimpleScheduleBuilder.withIntervalInSeconds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTrigger
import org.quartz.SimpleScheduleBuilder; //导入方法依赖的package包/类
@Override
public Trigger getTrigger() {
Checker.require(triggerKey).notNull();
TriggerBuilder<Trigger> triggerBuilder = newTrigger().withIdentity(triggerKey);
if (getStartTime() == null) {
triggerBuilder.startNow();
} else {
triggerBuilder.startAt(getStartTime());
}
if (getEndTime() != null) {
triggerBuilder.endAt(getEndTime());
}
if (isRepeatable()) {
SimpleScheduleBuilder scheduleBuilder = simpleSchedule();
scheduleBuilder.withIntervalInSeconds(getIntervalInSeconds());
if (isRepeatForever()) {
scheduleBuilder.repeatForever();
} else {
scheduleBuilder.withRepeatCount(getRepeatCount());
}
triggerBuilder.withSchedule(scheduleBuilder);
}
return triggerBuilder.build();
}
示例2: addSchedule
import org.quartz.SimpleScheduleBuilder; //导入方法依赖的package包/类
/**
* 增加一个调度任务
*
* @param name
* 任务名称
* @param job
* 执行内容
* @param intervalInHours
* 间隔小时
* @param intervalInMinutes
* 间隔分钟
* @param intervalInSeconds
* 间隔秒
* @param intervalInMillis
* 间隔毫秒
* @param repeatCount
* 重复次数
* @throws SchedulerException
*/
public Trigger addSchedule(String name, Class<? extends Job> task, int intervalInHours, int intervalInMinutes,
int intervalInSeconds, int intervalInMillis, int repeatCount, JobDataMap param) throws SchedulerException {
Scheduler sched = SF.getScheduler();
JobBuilder builder = JobBuilder.newJob(task);
builder.withIdentity(name, Scheduler.DEFAULT_GROUP);
if (param != null) {
builder.usingJobData(param);
}
SimpleScheduleBuilder simpleSchedule = SimpleScheduleBuilder.simpleSchedule();
if (intervalInHours > 0) {
simpleSchedule.withIntervalInHours(intervalInHours);
}
if (intervalInMinutes > 0) {
simpleSchedule.withIntervalInMinutes(intervalInMinutes);
}
if (intervalInSeconds > 0) {
simpleSchedule.withIntervalInSeconds(intervalInSeconds);
}
if (intervalInMillis > 0) {
simpleSchedule.withIntervalInMilliseconds(intervalInMillis);
}
if (repeatCount >= 0) {
simpleSchedule.withRepeatCount(repeatCount);
} else {
simpleSchedule.repeatForever();
}
Trigger trigger = TriggerBuilder.newTrigger().withIdentity(name, Scheduler.DEFAULT_GROUP)
.withSchedule(simpleSchedule).build();
sched.scheduleJob(builder.build(), trigger);
if (!sched.isShutdown())
sched.start();
return trigger;
}
示例3: simpleBuilderForever
import org.quartz.SimpleScheduleBuilder; //导入方法依赖的package包/类
/**
* 建立simpleTrigger repeatForever
* @param simpleBuilder
* @param job
* @return
*/
public SimpleScheduleBuilder simpleBuilderForever(SimpleScheduleBuilder simpleBuilder,ScheduleJob job){
if(job.getRepeatInterval()!=null){
if(job.getRepeatUnit().equals("hour")){
return simpleBuilder.withIntervalInHours(job.getRepeatInterval());
}else if(job.getRepeatUnit().equals("minute")){
return simpleBuilder.withIntervalInMinutes(job.getRepeatInterval());
}else{
return simpleBuilder.withIntervalInSeconds(job.getRepeatInterval());
}
}else{
return simpleBuilder.repeatForever();
}
}
示例4: buildTrigger
import org.quartz.SimpleScheduleBuilder; //导入方法依赖的package包/类
private Trigger buildTrigger(String name, String group, ScheduleRule scheduleRule) {
Trigger trigger;
Parameters triggerParameters = scheduleRule.getTriggerParameters();
Integer triggerStartDelaySeconds = triggerParameters.getInt(TriggerParameters.startDelaySeconds);
int intTriggerStartDelaySeconds = (triggerStartDelaySeconds != null) ? triggerStartDelaySeconds : 0;
Date firstFireTime;
if (startDelaySeconds > 0 || (triggerStartDelaySeconds != null && triggerStartDelaySeconds > 0)) {
firstFireTime = new Date(System.currentTimeMillis() + ((startDelaySeconds + intTriggerStartDelaySeconds) * 1000L));
} else {
firstFireTime = new Date();
}
if (scheduleRule.getTriggerType() == TriggerType.SIMPLE) {
Long intervalInMilliseconds = triggerParameters.getLong(TriggerParameters.intervalInMilliseconds);
Integer intervalInSeconds = triggerParameters.getInt(TriggerParameters.intervalInSeconds);
Integer intervalInMinutes = triggerParameters.getInt(TriggerParameters.intervalInMinutes);
Integer intervalInHours = triggerParameters.getInt(TriggerParameters.intervalInHours);
Integer repeatCount = triggerParameters.getInt(TriggerParameters.repeatCount);
Boolean repeatForever = triggerParameters.getBoolean(TriggerParameters.repeatForever);
SimpleScheduleBuilder builder = SimpleScheduleBuilder.simpleSchedule();
if (intervalInMilliseconds != null) {
builder.withIntervalInMilliseconds(intervalInMilliseconds);
}
if (intervalInMinutes != null) {
builder.withIntervalInMinutes(intervalInMinutes);
}
if (intervalInSeconds != null) {
builder.withIntervalInSeconds(intervalInSeconds);
}
if (intervalInHours != null) {
builder.withIntervalInHours(intervalInHours);
}
if (repeatCount != null) {
builder.withRepeatCount(repeatCount);
}
if (Boolean.TRUE.equals(repeatForever)) {
builder.repeatForever();
}
trigger = TriggerBuilder.newTrigger()
.withIdentity(name, group)
.startAt(firstFireTime)
.withSchedule(builder)
.build();
} else {
String expression = triggerParameters.getString(TriggerParameters.expression);
CronScheduleBuilder cronSchedule = CronScheduleBuilder.cronSchedule(expression);
trigger = TriggerBuilder.newTrigger()
.withIdentity(name, group)
.startAt(firstFireTime)
.withSchedule(cronSchedule)
.build();
}
return trigger;
}
示例5: configureTriggerJob
import org.quartz.SimpleScheduleBuilder; //导入方法依赖的package包/类
private Trigger configureTriggerJob(String jobName, String jobGroup, Job job) {
TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
// base trigger configuration
triggerBuilder.withIdentity(jobName, jobGroup);
if (job.getStartTime() != null)
triggerBuilder.startAt(job.getStartTime());
else {
if (job.getActive())
triggerBuilder.startNow();
}
if (job.getEndTime() != null)
triggerBuilder.endAt(job.getEndTime());
triggerBuilder.withPriority(job.getJobTriggerPriority());
// propietary trigger configuration
if (job.getJobTriggerType().getCode().equals(Job.JOB_TRIGGER_TYPE.SIMPLE.name())) {
SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
if (job.getJobInterval() != null) {
if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.SECOND.name()))
simpleScheduleBuilder.withIntervalInSeconds(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.MINUTE.name()))
simpleScheduleBuilder.withIntervalInMinutes(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.HOUR.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.DAY.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval() * 24);
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.WEEK.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval() * 24 * 7);
}
if (job.getRepeatCount() != null)
simpleScheduleBuilder.withRepeatCount(job.getRepeatCount());
else
simpleScheduleBuilder.repeatForever();
triggerBuilder.withSchedule(simpleScheduleBuilder);
}
else if (job.getJobTriggerType().getCode().equals(Job.JOB_TRIGGER_TYPE.CRON.name())) {
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
triggerBuilder.withSchedule(cronScheduleBuilder);
}
return triggerBuilder.build();
}