use of org.apache.karaf.scheduler.JobContext in project karaf by apache.
the class QuartzJobExecutor method execute.
/**
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
*/
public void execute(final JobExecutionContext context) throws JobExecutionException {
final JobDataMap data = context.getJobDetail().getJobDataMap();
final Object job = data.get(QuartzScheduler.DATA_MAP_OBJECT);
final Logger logger = (Logger) data.get(QuartzScheduler.DATA_MAP_LOGGER);
try {
logger.debug("Executing job {} with name {}", job, data.get(QuartzScheduler.DATA_MAP_NAME));
if (job instanceof org.apache.karaf.scheduler.Job) {
@SuppressWarnings("unchecked") final InternalScheduleOptions options = (InternalScheduleOptions) data.get(QuartzScheduler.DATA_MAP_OPTIONS);
final String name = (String) data.get(QuartzScheduler.DATA_MAP_NAME);
final JobContext jobCtx = new JobContextImpl(name, options.configuration);
((org.apache.karaf.scheduler.Job) job).execute(jobCtx);
} else if (job instanceof Runnable) {
((Runnable) job).run();
} else {
logger.error("Scheduled job {} is neither a job nor a runnable.", job);
}
} catch (final Throwable t) {
// there is nothing we can do here, so we just log
logger.error("Exception during job execution of " + job + " : " + t.getMessage(), t);
}
}
Aggregations