Search in sources :

Example 1 with ElasticJob

use of com.dangdang.ddframe.job.api.ElasticJob in project elastic-job by dangdangdotcom.

the class JobScheduler method createJobDetail.

private JobDetail createJobDetail(final String jobClass) {
    JobDetail result = JobBuilder.newJob(LiteJob.class).withIdentity(jobName).build();
    result.getJobDataMap().put(JOB_FACADE_DATA_MAP_KEY, jobFacade);
    Optional<ElasticJob> elasticJobInstance = createElasticJobInstance();
    if (elasticJobInstance.isPresent()) {
        result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, elasticJobInstance.get());
    } else if (!jobClass.equals(ScriptJob.class.getCanonicalName())) {
        try {
            result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, Class.forName(jobClass).newInstance());
        } catch (final ReflectiveOperationException ex) {
            throw new JobConfigurationException("Elastic-Job: Job class '%s' can not initialize.", jobClass);
        }
    }
    return result;
}
Also used : JobDetail(org.quartz.JobDetail) ScriptJob(com.dangdang.ddframe.job.api.script.ScriptJob) ElasticJob(com.dangdang.ddframe.job.api.ElasticJob) JobConfigurationException(com.dangdang.ddframe.job.exception.JobConfigurationException)

Aggregations

ElasticJob (com.dangdang.ddframe.job.api.ElasticJob)1 ScriptJob (com.dangdang.ddframe.job.api.script.ScriptJob)1 JobConfigurationException (com.dangdang.ddframe.job.exception.JobConfigurationException)1 JobDetail (org.quartz.JobDetail)1