use of org.quartz.CronTrigger in project pentaho-platform by pentaho.
the class QuartzSchedulerTest method testSetTimezone.
@Test
public void testSetTimezone() throws Exception {
CronTrigger cronTrigger = new CronTrigger();
cronTrigger.setCronExpression(new CronExpression("0 15 10 ? * 6L 2002-2018"));
String currentTimezoneId = TimeZone.getDefault().getID();
new QuartzScheduler().setTimezone(cronTrigger, currentTimezoneId);
assertNotNull(cronTrigger.getTimeZone());
assertEquals(currentTimezoneId, cronTrigger.getTimeZone().getID());
}
use of org.quartz.CronTrigger in project weicoder by wdcode.
the class CronTriggerSupport method toTabularData.
public static TabularData toTabularData(List<? extends CronTrigger> triggers) {
TabularData tData = new TabularDataSupport(TABULAR_TYPE);
if (triggers != null) {
ArrayList<CompositeData> list = new ArrayList<CompositeData>();
for (CronTrigger trigger : triggers) {
list.add(toCompositeData(trigger));
}
tData.putAll(list.toArray(new CompositeData[list.size()]));
}
return tData;
}
use of org.quartz.CronTrigger in project openhab1-addons by openhab.
the class MpdBinding method scheduleReconnect.
private void scheduleReconnect() {
Scheduler sched;
try {
sched = StdSchedulerFactory.getDefaultScheduler();
JobDetail job = newJob(ReconnectJob.class).withIdentity("Reconnect", MPD_SCHEDULER_GROUP).build();
CronTrigger trigger = newTrigger().withIdentity("Reconnect", MPD_SCHEDULER_GROUP).withSchedule(CronScheduleBuilder.cronSchedule("0 0 0 * * ?")).build();
sched.scheduleJob(job, trigger);
logger.debug("Scheduled a daily reconnect of all MPDs");
} catch (SchedulerException se) {
logger.warn("Scheduling MPD reconnect failed", se);
}
}
use of org.quartz.CronTrigger in project openhab1-addons by openhab.
the class FritzboxBinding method updated.
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("rawtypes")
public void updated(Dictionary config) throws ConfigurationException {
if (config != null) {
String ip = Objects.toString(config.get("ip"), null);
if (StringUtils.isNotBlank(ip)) {
if (!ip.equals(FritzboxBinding.ip)) {
// only do something if the ip has changed
FritzboxBinding.ip = ip;
conditionalDeActivate();
// and thus blocks the monitor thread
try {
Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
JobKey jobKey = jobKey("Reconnect", "FritzBox");
TriggerKey triggerKey = triggerKey("Reconnect", "FritzBox");
if (sched.checkExists(jobKey)) {
logger.debug("Daily reconnection job already exists");
} else {
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronSchedule);
JobDetail job = newJob(ReconnectJob.class).withIdentity(jobKey).build();
CronTrigger trigger = newTrigger().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
sched.scheduleJob(job, trigger);
logger.debug("Scheduled a daily reconnection to FritzBox on {}:{}", ip, MONITOR_PORT);
}
} catch (SchedulerException e) {
logger.warn("Could not create daily reconnection job", e);
}
}
}
String password = Objects.toString(config.get("password"), null);
if (StringUtils.isNotBlank(password)) {
FritzboxBinding.password = password;
}
String username = Objects.toString(config.get("user"), null);
if (StringUtils.isNotBlank(username)) {
FritzboxBinding.username = username;
}
}
}
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);
}
}
Aggregations