use of org.apache.syncope.core.provisioning.java.job.AbstractInterruptableJob in project syncope by apache.
the class AbstractJobLogic method getJobTO.
protected JobTO getJobTO(final JobKey jobKey) throws SchedulerException {
JobTO jobTO = null;
Triple<JobType, String, String> reference = getReference(jobKey);
if (reference != null) {
jobTO = new JobTO();
jobTO.setType(reference.getLeft());
jobTO.setRefKey(reference.getMiddle());
jobTO.setRefDesc(reference.getRight());
List<? extends Trigger> jobTriggers = scheduler.getScheduler().getTriggersOfJob(jobKey);
if (jobTriggers.isEmpty()) {
jobTO.setScheduled(false);
} else {
jobTO.setScheduled(true);
jobTO.setStart(jobTriggers.get(0).getStartTime());
}
jobTO.setRunning(jobManager.isRunning(jobKey));
jobTO.setStatus("UNKNOWN");
if (jobTO.isRunning()) {
try {
Object job = ApplicationContextProvider.getBeanFactory().getBean(jobKey.getName());
if (job instanceof AbstractInterruptableJob && ((AbstractInterruptableJob) job).getDelegate() != null) {
jobTO.setStatus(((AbstractInterruptableJob) job).getDelegate().currentStatus());
}
} catch (NoSuchBeanDefinitionException e) {
LOG.warn("Could not find job {} implementation", jobKey, e);
}
}
}
return jobTO;
}
Aggregations