本文整理汇总了Java中org.quartz.SimpleScheduleBuilder类的典型用法代码示例。如果您正苦于以下问题:Java SimpleScheduleBuilder类的具体用法?Java SimpleScheduleBuilder怎么用?Java SimpleScheduleBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleScheduleBuilder类属于org.quartz包,在下文中一共展示了SimpleScheduleBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshMetadata
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
/**
* Refresh metadata. Schedules the job to retrieve metadata.
* @throws SchedulerException the scheduler exception
*/
@PostConstruct
public void refreshMetadata() throws SchedulerException {
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
buildMetadataResolverAggregate();
}
});
thread.start();
final JobDetail job = JobBuilder.newJob(this.getClass())
.withIdentity(this.getClass().getSimpleName()).build();
final Trigger trigger = TriggerBuilder.newTrigger()
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMinutes(this.refreshIntervalInMinutes)
.repeatForever()).build();
final SchedulerFactory schFactory = new StdSchedulerFactory();
final Scheduler sch = schFactory.getScheduler();
sch.start();
sch.scheduleJob(job, trigger);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:StaticMetadataResolverAdapter.java
示例2: 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();
}
示例3: startAndSchedule
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
public synchronized void startAndSchedule(Integer jobIntervalSeconds) throws SchedulerException {
if (!scheduler.isStarted()) {
logger.debug(DEBUG_JOBS_INIT_STARTING_MESSAGE);
scheduler.start();
JobDetail job = JobBuilder.newJob(FetchEventsJob.class).build();
Trigger trigger = TriggerBuilder.newTrigger().startNow().withSchedule(
SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(jobIntervalSeconds).repeatForever())
.build();
scheduler.scheduleJob(job, trigger);
logger.debug(DEBUG_JOBS_INIT_DONE_MESSAGE);
} else {
logger.debug(DEBUG_SCHEDULER_IS_ALREADY_STARTED_MESSAGE);
}
}
示例4: getScheduleBuilder
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
/**
* Get a {@link ScheduleBuilder} that is configured to produce a
* schedule identical to this trigger's schedule.
*
* @see #getTriggerBuilder()
*/
@Override
public ScheduleBuilder<SimpleTrigger> getScheduleBuilder() {
SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMilliseconds(getRepeatInterval())
.withRepeatCount(getRepeatCount());
switch(getMisfireInstruction()) {
case MISFIRE_INSTRUCTION_FIRE_NOW : sb.withMisfireHandlingInstructionFireNow();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT : sb.withMisfireHandlingInstructionNextWithExistingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT : sb.withMisfireHandlingInstructionNextWithRemainingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithExistingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithRemainingCount();
break;
}
return sb;
}
示例5: enableSessionValidation
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
public void enableSessionValidation() {
if (log.isDebugEnabled()) {
log.debug("Scheduling session validation job using Quartz with session validation interval of ["
+ this.sessionValidationInterval + "]ms...");
}
try {
SimpleTrigger trigger = TriggerBuilder.newTrigger().startNow().withIdentity(JOB_NAME, Scheduler.DEFAULT_GROUP)
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInMilliseconds(sessionValidationInterval))
.build();
JobDetail detail = JobBuilder.newJob(QuartzSessionValidationJob.class)
.withIdentity(JOB_NAME, Scheduler.DEFAULT_GROUP).build();
detail.getJobDataMap().put(SESSION_MANAGER_KEY, this.sessionManager);
Scheduler scheduler = getScheduler();
scheduler.scheduleJob(detail, trigger);
if (this.schedulerImplicitlyCreated) {
scheduler.start();
if (log.isDebugEnabled()) {
log.debug("Successfully started implicitly created Quartz Scheduler instance.");
}
}
this.enabled = true;
if (log.isDebugEnabled())
log.debug("Session validation job successfully scheduled with Quartz.");
} catch (SchedulerException e) {
if (log.isErrorEnabled())
log.error("Error starting the Quartz session validation job. Session validation may not occur.", e);
}
}
示例6: run
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
@Override
public void run(String... strings) throws Exception {
try {
/*
* 在 Quartz 中, scheduler 由 SchedulerFactory创建:DirectSchedulerFactory 或者
* StdSchedulerFactory。第二种工厂 StdSchedulerFactory 使用较多,因为
* DirectSchedulerFactory 使用起来不够方便,需要作许多详细的手工编码设置。
*/
// 获取Scheduler实例
scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
// System.out.println("scheduler.start");
// System.out.println(scheduler.getSchedulerName());
// 注册任务
JobDetail jobDetail = JobBuilder.newJob(QuartzTask.class).withIdentity("QuartzTaskJob", "QuartzTaskGroup").build();
// 设置出发时间(每1天执行1次)
SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(24).repeatForever();
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger", "group").startNow().withSchedule(simpleScheduleBuilder).build();
// 交由Scheduler安排触发
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
e.printStackTrace();
}
}
示例7: convert
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
@Override
public Trigger convert(Immediate trigger) {
SimpleScheduleBuilder simpleSchedule = SimpleScheduleBuilder.simpleSchedule();
if (trigger.getMisfireInstruction() == Immediate.MisfireInstruction.DROP) {
simpleSchedule = simpleSchedule.withMisfireHandlingInstructionIgnoreMisfires();
} else if (trigger.getMisfireInstruction() == Immediate.MisfireInstruction.FIRE_NOW) {
simpleSchedule = simpleSchedule.withMisfireHandlingInstructionFireNow();
}
return newTrigger()
.withIdentity(trigger.getTriggerKey().getName(), trigger.getTriggerKey().getGroup())
.forJob(trigger.getJobKey().getName(), trigger.getJobKey().getGroup())
.withDescription(trigger.getDescription())
.withSchedule(simpleSchedule)
.usingJobData(new JobDataMap(trigger.getTriggerData()))
.startNow()
.build();
}
示例8: prvateAddQuartz
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
private boolean prvateAddQuartz(Class<? extends Job> jobClass,JobKey jobKey, CronScheduleBuilder builder, SimpleScheduleBuilder repeatForever) {
if(scheduler==null){
init();
}
//创建一个任务计划生成器 设置任务名称与分组 创建任务计划
JobDetail job = JobBuilder.newJob(jobClass).withIdentity(jobKey).build();
//创建一个触发生成器 设置触发器名称与分组 设置触发器出发条件 创建触发器
Trigger trigger = TriggerBuilder.newTrigger().withIdentity(jobKey.getName(),jobKey.getGroup()).withSchedule(builder==null?repeatForever:builder).build();
try {
scheduler.scheduleJob(job, trigger);
outLog("添加任务计划成功!");
return true;
} catch (SchedulerException e) {
outLog("添加任务计划失败!");
}
return false;
}
示例9: main
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
public static void main(String[] args) {
try {
final Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
final JobDetail job = JobBuilder.newJob(MailFilterJob.class).build();
final Trigger trigger = TriggerBuilder.newTrigger()
.startNow()
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMinutes(15)
.repeatForever())
.build();
scheduler.scheduleJob(job, trigger);
} catch (SchedulerException ex) {
Logger.getLogger(MailFilterService.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例10: main
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
/**
* Starts the main program and schedules the twitter post stats job
* @param args (unused array of strings)
*/
public static void main(String[] args) throws IOException {
logMsg("Twitter poster started...\n");
// Set the job logging level to "ERROR" and
// schedule the station updater for every 60 seconds
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "ERROR");
JobDetail job = JobBuilder.newJob(TwitterPostStatsJob.class)
.withIdentity("twitterPostStatsJob").build();
Trigger trigger = TriggerBuilder.newTrigger()
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(60).repeatForever()).build();
// Schedule the twitter post stats job
try {
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
sched.start();
sched.scheduleJob(job, trigger);
} catch (SchedulerException e) {
logMsg("Error running the twitter post stats job...");
e.printStackTrace();
}
}
示例11: SparkRedisStreaming
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
public SparkRedisStreaming() throws NumberFormatException, Exception{
// Quartz 1.6.3
JobDetail job = JobBuilder.newJob(SparkRedisStreaming.class).withIdentity("SparkRedisStreaming", "SparkRedisStreaming").build();
// Trigger the job to run on the next round minute
Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity("SparkRedisStreaming", "SparkRedisStreaming")
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(Integer.valueOf(getConfiguration().get("streaming.persistTime"))).repeatForever()).build();
// schedule it
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);
}
示例12: createRepeatingTask
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static TaskBase createRepeatingTask(@Nonnull Class<? extends TaskCallback> commandClass,
long interval, long initialDelay) {
checkCommandClass(commandClass, false);
Class<QuartzCommand> quartzCommand = (Class<QuartzCommand>) commandClass;
JobDetail jobDetail = JobBuilder.newJob(quartzCommand).withIdentity(generateUniqueName(quartzCommand),
QuartzTask.ARTIFACTORY_GROUP).build();
SimpleScheduleBuilder schedulerBuilder = SimpleScheduleBuilder.simpleSchedule();
if (interval > 0) {
schedulerBuilder.repeatForever().withIntervalInMilliseconds(interval);
}
Trigger trigger = TriggerBuilder.newTrigger().forJob(jobDetail)
.withIdentity(generateUniqueName(quartzCommand))
.withSchedule(schedulerBuilder).startAt(new Date(System.currentTimeMillis() + initialDelay)).build();
return fillProperties(QuartzTask.createQuartzTask(commandClass, trigger, jobDetail), false);
}
示例13: buildTrigger
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
protected OperableTrigger buildTrigger(String triggerName,
String triggerGroup,
JobDetail job,
Long startAt,
Long endAt,
ScheduleBuilder scheduleBuilder) {
ScheduleBuilder schedule = scheduleBuilder!=null?scheduleBuilder : SimpleScheduleBuilder.simpleSchedule();
return (OperableTrigger) TriggerBuilder
.newTrigger()
.withIdentity(triggerName, triggerGroup)
.forJob(job)
.startAt(startAt != null ? new Date(startAt) : null)
.endAt(endAt != null ? new Date(endAt) : null)
.withSchedule(schedule)
.build();
}
示例14: createAndExecuteJob
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
public static void createAndExecuteJob(String callerResult, JobExecutionContext context) {
try {
JobDetail job = newJob(RESTJob.class)
.withIdentity(UUID.randomUUID().toString(), UUID.randomUUID().toString())
//.usingJobData("#callerJobName", context.getJobDetail().getKey().getName())
//.usingJobData("#callerJobGroup", context.getJobDetail().getKey().getGroup())
.usingJobData("#url", callerResult)
.storeDurably(false)
.build();
Trigger trigger = newTrigger()
.withIdentity(TriggerKey.triggerKey(UUID.randomUUID().toString(), UUID.randomUUID().toString()))
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(0))
.startNow()
.build();
context.getScheduler().scheduleJob(job, trigger);
} catch (SchedulerException e) {
e.printStackTrace(System.out);
//don't throw a JobExecutionException if a job execution, invoked by this job, fails
}
}
示例15: createAndExecuteJob
import org.quartz.SimpleScheduleBuilder; //导入依赖的package包/类
public static void createAndExecuteJob(String callerResult, JobExecutionContext context) {
try {
JobDetail job = newJob(RESTJob.class)
.withIdentity(UUID.randomUUID().toString(), UUID.randomUUID().toString())
//.usingJobData("#callerJobName", context.getJobDetail().getKey().getName())
//.usingJobData("#callerJobGroup", context.getJobDetail().getKey().getGroup())
.usingJobData("#url", callerResult)
.storeDurably(false)
.build();
Trigger trigger = newTrigger()
.withIdentity(TriggerKey.triggerKey(UUID.randomUUID().toString(), UUID.randomUUID().toString()))
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(0))
.startNow()
.build();
context.getScheduler().scheduleJob(job, trigger);
} catch (SchedulerException e) {
e.printStackTrace();
//don't throw a JobExecutionException if a job execution, invoked by this job, fails
}
}