* {@inheritDoc}
*/
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
final ApplicationContext ctx = ((ConfigurableApplicationContext) schedulerContext.get("applicationContext"));
// Try to re-create job bean from underlying task (useful for managing
// failover scenarios)
if (!ctx.containsBean(bundle.getJobDetail().getKey().getName())) {
Long taskId = JobInstanceLoader.getTaskIdFromJobName(bundle.getJobDetail().getKey().getName());
if (taskId != null) {
TaskDAO taskDAO = ctx.getBean(TaskDAO.class);
SchedTask task = taskDAO.find(taskId);
JobInstanceLoader jobInstanceLoader = ctx.getBean(JobInstanceLoader.class);
jobInstanceLoader.registerJob(task, task.getJobClassName(), task.getCronExpression());
}
Long reportId = JobInstanceLoader.getReportIdFromJobName(bundle.getJobDetail().getKey().getName());
if (reportId != null) {
ReportDAO reportDAO = ctx.getBean(ReportDAO.class);
Report report = reportDAO.find(reportId);
JobInstanceLoader jobInstanceLoader = ctx.getBean(JobInstanceLoader.class);
jobInstanceLoader.registerJob(report);
}
}
final Object job = ctx.getBean(bundle.getJobDetail().getKey().getName());
final BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(job);
if (isEligibleForPropertyPopulation(wrapper.getWrappedInstance())) {
final MutablePropertyValues pvs = new MutablePropertyValues();
if (this.schedulerContext != null) {
pvs.addPropertyValues(this.schedulerContext);