use of org.quartz.JobDetail in project openhab1-addons by openhab.
the class FHTBinding method scheduleJob.
/**
* The user may configure this binding to update the internal clock of
* FHT80b devices via rf command. The method takes care of scheduling this
* job.
*/
private JobKey scheduleJob(Class<? extends Job> jobClass, String cronExpression) {
JobKey jobKey = null;
try {
Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
JobDetail detail = JobBuilder.newJob(jobClass).withIdentity("FHT " + jobClass.getSimpleName(), "cul").build();
detail.getJobDataMap().put(FHTBinding.class.getName(), this);
CronTrigger trigger = TriggerBuilder.newTrigger().forJob(detail).withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build();
jobKey = detail.getKey();
sched.scheduleJob(detail, trigger);
} catch (SchedulerException e) {
logger.error("Can't schedule time update job", e);
}
return jobKey;
}
use of org.quartz.JobDetail in project openhab1-addons by openhab.
the class MapDBPersistenceService method scheduleJob.
/**
* Schedules new quartz scheduler jobs for committing transactions and
* backing up the database
*/
private void scheduleJob() {
try {
Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
// schedule commit-job
JobDetail job = newJob(CommitJob.class).withIdentity("Commit_Transaction", SCHEDULER_GROUP).build();
SimpleTrigger trigger = newTrigger().withIdentity("Commit_Transaction", SCHEDULER_GROUP).withSchedule(repeatSecondlyForever(commitInterval)).build();
sched.scheduleJob(job, trigger);
logger.debug("Scheduled Commit-Job with interval {}sec.", commitInterval);
} catch (SchedulerException e) {
logger.warn("Could not create Job: {}", e.getMessage());
}
}
use of org.quartz.JobDetail in project openhab1-addons by openhab.
the class GCalPersistenceService method scheduleUploadJob.
/**
* Schedules new quartz scheduler job for uploading calendar entries to Google
*/
private void scheduleUploadJob() {
try {
scheduler = StdSchedulerFactory.getDefaultScheduler();
JobDetail job = newJob(SynchronizationJob.class).withIdentity("Upload_GCal-Entries", GCAL_SCHEDULER_GROUP).build();
SimpleTrigger trigger = newTrigger().withIdentity("Upload_GCal-Entries", GCAL_SCHEDULER_GROUP).withSchedule(repeatSecondlyForever(uploadInterval)).build();
scheduler.scheduleJob(job, trigger);
logger.debug("Scheduled Google Calendar Upload-Job with interval '{}'", uploadInterval);
} catch (SchedulerException e) {
logger.warn("Could not create Google Calendar Upload-Job: {}", e.getMessage());
}
}
use of org.quartz.JobDetail in project openhab1-addons by openhab.
the class Db4oPersistenceService method scheduleJob.
/**
* Schedules new quartz scheduler jobs for committing transactions and
* backing up the database
*/
private void scheduleJob() {
try {
Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
// schedule commit-job
JobDetail job = newJob(CommitJob.class).withIdentity("Commit_Transaction", SCHEDULER_GROUP).build();
SimpleTrigger trigger = newTrigger().withIdentity("Commit_Transaction", SCHEDULER_GROUP).withSchedule(repeatSecondlyForever(commitInterval)).build();
sched.scheduleJob(job, trigger);
logger.debug("Scheduled Commit-Job with interval {}sec.", commitInterval);
// schedule backup-job
JobDetail backupJob = newJob(BackupJob.class).withIdentity("Backup_DB", SCHEDULER_GROUP).build();
CronTrigger backupTrigger = newTrigger().withIdentity("Backup_DB", SCHEDULER_GROUP).withSchedule(CronScheduleBuilder.cronSchedule(backupInterval)).build();
sched.scheduleJob(backupJob, backupTrigger);
logger.debug("Scheduled Backup-Job with cron expression '{}'", backupInterval);
} catch (SchedulerException e) {
logger.warn("Could not create Job: {}", e.getMessage());
}
}
use of org.quartz.JobDetail in project OpenClinica by OpenClinica.
the class XsltTransformJob method postErrorMessage.
private void postErrorMessage(String message, JobExecutionContext context) {
String SCHEDULER = "schedulerFactoryBean";
try {
ApplicationContext appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
StdScheduler scheduler = (StdScheduler) appContext.getBean(SCHEDULER);
JobDetail jobDetail = context.getJobDetail();
JobDataMap dataMap = jobDetail.getJobDataMap();
dataMap.put("failMessage", message);
jobDetail.getJobBuilder().usingJobData(dataMap);
// replace the job with the extra data
scheduler.addJob(jobDetail, true);
} catch (SchedulerException e) {
throw new IllegalStateException("Error processing post error message", e);
}
}
Aggregations