/** * 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 * @param jobParameters The JobParameters to use during the launch * @return JobExecution */ public JobExecution launchStep(Step step, JobParameters jobParameters) { return this.launchStep(step, jobParameters, null); }
/** * Launch just the specified step as its own job. A unique set of * JobParameters will automatically be generated. An IllegalStateException * is thrown if there is no Step with the given name. * * @param step The step to launch * @return JobExecution */ public JobExecution launchStep(Step step) { return this.launchStep(step, this.makeUniqueJobParameters(), null); }
/** * Launch just the specified step as its own job. A unique set of * JobParameters will automatically be generated. An IllegalStateException * is thrown if there is no Step with the given name. * * @param step The step to 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, @Nullable ExecutionContext jobExecutionContext) { return this.launchStep(step, this.makeUniqueJobParameters(), jobExecutionContext); }
/** * Launch just the specified step in the job. An IllegalStateException is * thrown if there is no Step with the given name. * * @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(String stepName, JobParameters jobParameters, @Nullable ExecutionContext jobExecutionContext) { if (!(job instanceof StepLocator)) { throw new UnsupportedOperationException("Cannot locate step from a Job that is not a StepLocator: job=" + job.getName() + " does not implement StepLocator"); } StepLocator locator = (StepLocator) this.job; Step step = locator.getStep(stepName); if (step == null) { step = locator.getStep(this.job.getName() + "." + stepName); } if (step == null) { throw new IllegalStateException("No Step found with name: [" + stepName + "]"); } return getStepRunner().launchStep(step, jobParameters, jobExecutionContext); } }
/** * Launch just the specified step in the job. An IllegalStateException is * thrown if there is no Step with the given name. * * @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(String stepName, JobParameters jobParameters, ExecutionContext jobExecutionContext) { Step step = this.job.getStep(stepName); if (step == null) { step = this.job.getStep(this.job.getName() + "." + stepName); } if (step == null) { throw new IllegalStateException("No Step found with name: [" + stepName + "]"); } return getStepRunner().launchStep(step, jobParameters, jobExecutionContext); } }
@Test public void testTasklet() { Step step = (Step) context.getBean("s2"); assertEquals(BatchStatus.COMPLETED, stepRunner.launchStep(step).getStatus()); assertEquals(2, jdbcTemplate.queryForObject("SELECT ID from TESTS where NAME = 'SampleTasklet2'", Integer.class).intValue()); }
/** * Launcher * * @param stepName */ public JobExecution launchStep(Step step) { return this.launchStep(step, this.makeUniqueJobParameters()); }
/** * Launch just the specified step in the job. An IllegalStateException is * thrown if there is no Step with the given name. * * @param stepName * @return JobExecution */ public JobExecution launchStep(String stepName) { Step step = this.job.getStep(stepName); if (step == null) { throw new IllegalStateException("No Step found with name: [" + stepName + "]"); } return getStepRunner().launchStep(step); }
/** * Launch just the specified step in the job. * * @param stepName * @param jobParameters */ public JobExecution launchStep(String stepName, JobParameters jobParameters) { return getStepRunner().launchStep(this.job.getStep(stepName), jobParameters); } }