Search in sources :

Example 1 with AstroConfig

use of org.openhab.binding.astro.internal.common.AstroConfig in project openhab1-addons by openhab.

the class JobScheduler method scheduleIntervalJob.

/**
     * Schedules the IntervalJob with the specified interval and starts it
     * immediately.
     */
public void scheduleIntervalJob() {
    AstroConfig config = context.getConfig();
    String jobName = IntervalJob.class.getSimpleName();
    Date start = new Date(System.currentTimeMillis() + (config.getInterval()) * 1000);
    Trigger trigger = newTrigger().withIdentity(jobName + "-Trigger", JOB_GROUP).startAt(start).withSchedule(simpleSchedule().repeatForever().withIntervalInSeconds(config.getInterval())).build();
    schedule(jobName, IntervalJob.class, trigger, new JobDataMap());
    logger.info("Scheduled astro job with interval of {} seconds", config.getInterval());
}
Also used : JobDataMap(org.quartz.JobDataMap) Trigger(org.quartz.Trigger) CronTrigger(org.quartz.CronTrigger) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) AstroConfig(org.openhab.binding.astro.internal.common.AstroConfig) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 AstroConfig (org.openhab.binding.astro.internal.common.AstroConfig)1 CronTrigger (org.quartz.CronTrigger)1 JobDataMap (org.quartz.JobDataMap)1 Trigger (org.quartz.Trigger)1 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)1