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

com.github.ltsopensource.spring.quartz.invoke.JobDetailJobExecution Maven / Gradle / Ivy

The newest version!
package com.github.ltsopensource.spring.quartz.invoke;

import com.github.ltsopensource.core.commons.utils.CollectionUtils;
import com.github.ltsopensource.core.domain.Job;
import com.github.ltsopensource.spring.quartz.QuartzJobContext;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.core.jmx.JobDataMapSupport;

import java.util.Map;

/**
 * @author Robert HG ([email protected]) on 3/27/16.
 */
public class JobDetailJobExecution implements JobExecution {

    private org.quartz.Job quartzJob;

    public JobDetailJobExecution(org.quartz.Job quartzJob) {
        this.quartzJob = quartzJob;
    }

    @Override
    public void execute(QuartzJobContext quartzJobContext, Job job) throws Throwable {

        JobDataMap jobDataMap = JobDataMapSupport.newJobDataMap(quartzJobContext.getJobDataMap());

        // 用lts的覆盖
        Map map = job.getExtParams();
        if (CollectionUtils.isNotEmpty(map)) {
            for (Map.Entry entry : map.entrySet()) {
                jobDataMap.put(entry.getKey(), entry.getValue());
            }
        }

        JobExecutionContext jobExecutionContext = new JobExecutionContextImpl(jobDataMap);
        quartzJob.execute(jobExecutionContext);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy