List of usage examples for org.springframework.batch.core.job SimpleJob setSteps
public void setSteps(List<Step> steps)
From source file:trionsoft.test.StepRunner.java
/** * Launch just the specified step as its own job. An IllegalStateException * is thrown if there is no Step with the given name. * /*from ww w.j a v a 2 s.co m*/ * @param stepName The name of the step to launch * @param jobParameters The JobParameters to use during the launch * @param jobExecutionContext An ExecutionContext whose values will be * loaded into the Job ExecutionContext prior to launching the step. * @return JobExecution */ public JobExecution launchStep(Step step, JobParameters jobParameters, final ExecutionContext jobExecutionContext) { // // Create a fake job // SimpleJob job = new SimpleJob(); job.setName("TestJob"); job.setJobRepository(this.jobRepository); List<Step> stepsToExecute = new ArrayList<Step>(); stepsToExecute.add(step); job.setSteps(stepsToExecute); // // Dump the given Job ExecutionContext using a listener // if (jobExecutionContext != null && !jobExecutionContext.isEmpty()) { job.setJobExecutionListeners(new JobExecutionListener[] { new JobExecutionListenerSupport() { public void beforeJob(JobExecution jobExecution) { ExecutionContext jobContext = jobExecution.getExecutionContext(); for (Map.Entry<String, Object> entry : jobExecutionContext.entrySet()) { jobContext.put(entry.getKey(), entry.getValue()); } } } }); } // // Launch the job // return this.launchJob(job, jobParameters); }
From source file:org.springframework.batch.test.StepRunner.java
/** * Launch just the specified step as its own job. An IllegalStateException * is thrown if there is no Step with the given name. * * @param step The step to launch//from www . j av a 2 s .c o m * @param jobParameters The JobParameters to use during the launch * @param jobExecutionContext An ExecutionContext whose values will be * loaded into the Job ExecutionContext prior to launching the step. * @return JobExecution */ public JobExecution launchStep(Step step, JobParameters jobParameters, final ExecutionContext jobExecutionContext) { // // Create a fake job // SimpleJob job = new SimpleJob(); job.setName("TestJob"); job.setJobRepository(this.jobRepository); List<Step> stepsToExecute = new ArrayList<Step>(); stepsToExecute.add(step); job.setSteps(stepsToExecute); // // Dump the given Job ExecutionContext using a listener // if (jobExecutionContext != null && !jobExecutionContext.isEmpty()) { job.setJobExecutionListeners(new JobExecutionListener[] { new JobExecutionListenerSupport() { @Override public void beforeJob(JobExecution jobExecution) { ExecutionContext jobContext = jobExecution.getExecutionContext(); for (Map.Entry<String, Object> entry : jobExecutionContext.entrySet()) { jobContext.put(entry.getKey(), entry.getValue()); } } } }); } // // Launch the job // return this.launchJob(job, jobParameters); }