com.github.dynamicextensionsalfresco.schedule.quartz.QuartzJobAdaptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scheduler-quartz-1 Show documentation
Show all versions of scheduler-quartz-1 Show documentation
Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features
package com.github.dynamicextensionsalfresco.schedule.quartz;
import com.github.dynamicextensionsalfresco.schedule.Task;
import java.util.Map;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class QuartzJobAdaptor {
static void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
JobDetail jobDetail = jobExecutionContext.getJobDetail();
Map jobDataMap = jobDetail.getJobDataMap();
Object obj = jobDataMap.get(QuartzTaskScheduler.BEAN_ID);
if (obj == null) {
throw new JobExecutionException(String.format("Job not found in %s", JobDataMap.class.getSimpleName()));
}
if (Task.class.isAssignableFrom(obj.getClass())) {
Task task = (Task) obj;
task.execute();
} else if (Job.class.isAssignableFrom(obj.getClass())) {
Job lockedJob = (Job) obj;
lockedJob.execute(jobExecutionContext);
} else {
throw new JobExecutionException("Unexpected type: " + obj.getClass());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy