I am curious is it possible to define Spring Batch Job other way then a creating a bean by method. Is any way to define Batch Job by creating a @Component which extend Job and using injected JobBuilderFactory to create a instance to avoid implementing all required method by own hand ?
@Component
public class ImportEmployeeJob extends FlowJob {
private final JobBuilderFactory jobBuilderFactory;
private final FlowStep printProcessedEmployeeFromCsv;
public ImportEmployeeJob(JobBuilderFactory jobBuilderFactory, FlowStep printProcessedEmployeeFromCsv, ApplicationContext context) {
this.jobBuilderFactory = jobBuilderFactory;
this.printProcessedEmployeeFromCsv = printProcessedEmployeeFromCsv;
jobBuilderFactory.get("importEmployeeJob")
.incrementer(new RunIdIncrementer())
.listener(new PersonCsvJobExecutionListener())
.flow(printProcessedEmployeeFromCsv)
.end()
.build();
}
}
This is little stupid example but i just want to show you what i mean