use of com.dangdang.ddframe.job.exception.JobConfigurationException 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;
}
use of com.dangdang.ddframe.job.exception.JobConfigurationException in project elastic-job by dangdangdotcom.
the class ScriptJobExecutor method executeScript.
private void executeScript(final ShardingContext shardingContext, final String scriptCommandLine) {
CommandLine commandLine = CommandLine.parse(scriptCommandLine);
commandLine.addArgument(GsonFactory.getGson().toJson(shardingContext), false);
try {
new DefaultExecutor().execute(commandLine);
} catch (final IOException ex) {
throw new JobConfigurationException("Execute script failure.", ex);
}
}
Aggregations