use of org.quartz.JobDataMap in project openhab1-addons by openhab.
the class AbstractBaseJob method execute.
@Override
public void execute(JobExecutionContext jobContext) throws JobExecutionException {
JobDataMap jobDataMap = jobContext.getJobDetail().getJobDataMap();
if (logger.isDebugEnabled()) {
String itemName = jobDataMap.getString("itemName");
if (itemName != null) {
logger.debug("Starting Astro {} for item {}", this.getClass().getSimpleName(), itemName);
} else {
logger.debug("Starting Astro {}", this.getClass().getSimpleName());
}
}
executeJob(jobDataMap);
}
use of org.quartz.JobDataMap 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());
}
use of org.quartz.JobDataMap in project openhab1-addons by openhab.
the class JobScheduler method scheduleItem.
/**
* Schedules a item job at the specified date/time from the calendar object.
*/
public void scheduleItem(Calendar calendar, String itemName) {
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("itemName", itemName);
schedule(calendar, itemName, jobDataMap, ItemJob.class);
}
use of org.quartz.JobDataMap in project openhab1-addons by openhab.
the class JobScheduler method scheduleSeasonJob.
/**
* Schedules next Season job.
*/
public void scheduleSeasonJob(Season season) {
Calendar nextSeason = season.getNextSeason();
if (nextSeason == null) {
nextSeason = DateTimeUtils.getFirstDayOfNextYear();
}
schedule(nextSeason, "Season", new JobDataMap(), SeasonJob.class);
}
use of org.quartz.JobDataMap in project camel by apache.
the class QuartzManuallyTriggerJobTest method testQuartzCronRoute.
@Test
public void testQuartzCronRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
QuartzComponent component = context.getComponent("quartz2", QuartzComponent.class);
Scheduler scheduler = component.getScheduler();
// collect all jobKeys of this route (ideally only one).
ArrayList<JobKey> jobKeys = new ArrayList<JobKey>();
for (String group : scheduler.getJobGroupNames()) {
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(group))) {
jobKeys.add(jobKey);
}
}
JobDataMap jobDataMap = scheduler.getJobDetail(jobKeys.get(0)).getJobDataMap();
// trigger job manually
scheduler.triggerJob(jobKeys.get(0), jobDataMap);
assertMockEndpointsSatisfied();
}
Aggregations