use of com.dangdang.ddframe.job.api.simple.SimpleJob in project loc-framework by lord-of-code.
the class LocElasticJobAutoConfiguration method createBean.
private void createBean(ZookeeperRegistryCenter registryCenter, @Nullable JobEventConfiguration jobEventConfiguration, String[] jobs) {
if (ArrayUtils.isNotEmpty(jobs)) {
Arrays.stream(jobs).forEach(job -> {
try {
ElasticJob elasticJob = this.applicationContext.getBean(job, ElasticJob.class);
LocElasticJob locElasticJob = elasticJob.getClass().getAnnotation(LocElasticJob.class);
LiteJobConfiguration liteJobConfiguration;
if (elasticJob instanceof SimpleJob) {
liteJobConfiguration = createSimpleJobLiteJobConfiguration(elasticJob, locElasticJob);
} else if (elasticJob instanceof DataflowJob) {
liteJobConfiguration = createDataFlowJobConfiguration(elasticJob, locElasticJob);
} else if (elasticJob instanceof ScriptJob) {
liteJobConfiguration = createScriptJobConfiguration(elasticJob, locElasticJob);
} else {
throw new IllegalArgumentException("error elasticJob type");
}
Preconditions.checkNotNull(liteJobConfiguration, "liteJobConfiguration不能为空");
ElasticJobListener[] elasticJobListeners = getElasticJobListeners(locElasticJob.elasticJobListeners());
List<Object> argList = Lists.newArrayList();
if (elasticJob instanceof ScriptJob) {
argList.add(null);
} else {
argList.add(elasticJob);
}
argList.add(registryCenter);
argList.add(liteJobConfiguration);
Optional.ofNullable(jobEventConfiguration).ifPresent(argList::add);
argList.add(elasticJobListeners);
createSpringJobScheduler(elasticJob.getClass().getSimpleName() + "JobScheduler", argList);
} catch (Exception e) {
throw Throwables.propagate(e);
}
});
}
}
Aggregations