All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.schedule.quartz.QuartzJobAdaptor Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 2.1.4
Show newest version
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