/** * Convenient method for subclasses to grab a {@link StepRunner} for running * steps by name. * * @return a {@link StepRunner} */ protected StepRunner getStepRunner() { if (this.stepRunner == null) { this.stepRunner = new StepRunner(getJobLauncher(), getJobRepository()); } return this.stepRunner; }
/** * 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. 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); }
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);) { String getCurrentLine; StepRunner stepRunner = new StepRunner(); @Override public void run() { stepRunner.runStep(currentLine);
return this.launchJob(job, jobParameters);
/** * 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. * * @param stepName * @param jobParameters */ public JobExecution launchStep(Step step, JobParameters jobParameters) { // // 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); // // Launch the job // return this.launchJob(job, jobParameters); }
/** * 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); }
/** * Convenient method for subclasses to grab a {@link StepRunner} for running * steps by name. * * @return a {@link StepRunner} */ protected StepRunner getStepRunner() { if (this.stepRunner == null) { this.stepRunner = new StepRunner(getJobLauncher(), getJobRepository()); } return this.stepRunner; }
/** * 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); } }
/** * Launcher * * @param stepName */ public JobExecution launchStep(Step step) { return this.launchStep(step, this.makeUniqueJobParameters()); }
@Before public void setUp() { jdbcTemplate.update("create table TESTS (ID integer, NAME varchar(40))"); stepRunner = new StepRunner(jobLauncher, jobRepository); }
@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()); }
/** * Convenient method for subclasses to grab a {@link StepRunner} for running * steps by name. * * @return a {@link StepRunner} */ protected StepRunner getStepRunner() { if (this.stepRunner == null) { this.stepRunner = new StepRunner(getJobLauncher(), getJobRepository()); } return this.stepRunner; }
/** * 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); } }