use of org.quartz.CronTrigger in project openhab1-addons by openhab.
the class CallMonitor method setupReconnectJob.
/***
* reset the connection to fbox periodically
*/
public void setupReconnectJob() {
try {
// String cronPattern = "0 0 0 * * ?"; //every day
// String cronPattern = "0 * * * * ?"; //every minute
// every 2 hrs
String cronPattern = "0 0 0/2 * * ?";
Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
JobKey jobKey = jobKey("Reconnect", "FritzBox");
TriggerKey triggerKey = triggerKey("Reconnect", "FritzBox");
if (sched.checkExists(jobKey)) {
logger.debug("reconnection job already exists");
} else {
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronPattern);
JobDetail job = newJob(ReconnectJob.class).withIdentity(jobKey).build();
CronTrigger trigger = newTrigger().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
sched.scheduleJob(job, trigger);
logger.debug("Scheduled reconnection job to FritzBox: {}", cronPattern);
}
} catch (SchedulerException e) {
logger.warn("Could not create daily reconnection job", e);
}
}
use of org.quartz.CronTrigger in project camel by apache.
the class QuartzComponent method createCronTrigger.
protected CronTrigger createCronTrigger(String path) throws ParseException {
CronTrigger cron = new CronTrigger();
cron.setCronExpression(path);
return cron;
}
use of org.quartz.CronTrigger in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureAnotherCronExpression.
@Test
public void testConfigureAnotherCronExpression() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz://myGroup/myTimerName?cron=0+0+*+*+*+?");
CronTrigger trigger = assertIsInstanceOf(CronTrigger.class, endpoint.getTrigger());
assertEquals("getName()", "myTimerName", trigger.getName());
assertEquals("getGroup()", "myGroup", trigger.getGroup());
assertEquals("cron expression", "0 0 * * * ?", trigger.getCronExpression());
// default job name
assertEquals("getJobName", "quartz-" + endpoint.getId(), endpoint.getJobName());
}
use of org.quartz.CronTrigger in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureJobName.
@Test
public void testConfigureJobName() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz://myGroup/myTimerName?job.name=hadrian&cron=0+0+*+*+*+?");
CronTrigger trigger = assertIsInstanceOf(CronTrigger.class, endpoint.getTrigger());
assertEquals("getName()", "myTimerName", trigger.getName());
assertEquals("getGroup()", "myGroup", trigger.getGroup());
assertEquals("cron expression", "0 0 * * * ?", trigger.getCronExpression());
assertEquals("getJobName", "hadrian", endpoint.getJobName());
}
use of org.quartz.CronTrigger in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureNoDoubleSlashQuestionCron.
@Test
public void testConfigureNoDoubleSlashQuestionCron() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz:myGroup/myTimerName?cron=0+0+*+*+*+?");
CronTrigger trigger = assertIsInstanceOf(CronTrigger.class, endpoint.getTrigger());
assertEquals("getName()", "myTimerName", trigger.getName());
assertEquals("getGroup()", "myGroup", trigger.getGroup());
assertEquals("cron expression", "0 0 * * * ?", trigger.getCronExpression());
}
Aggregations