BATCH-1132:
*Updated parsers to handle 'parent' attribute of <step/>. *Attribute "parent" can be used on standalone and inline step declaration as well as with the 'tasklet' attribute. *To be consistent with treatment of listeners and tasklets, 'parent' can't be combined with 'ref' on <step/>.
This commit is contained in:
@@ -201,11 +201,6 @@ public class SkipSampleFunctionalTests {
|
||||
}
|
||||
|
||||
private Map<String, Object> getStepExecution(long jobExecutionId, String stepName) {
|
||||
for (Map<String, Object> rs : simpleJdbcTemplate.queryForList(
|
||||
"SELECT * from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? and STEP_NAME = ?", jobExecutionId,
|
||||
stepName)) {
|
||||
System.err.println(rs);
|
||||
}
|
||||
return simpleJdbcTemplate.queryForMap(
|
||||
"SELECT * from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? and STEP_NAME = ?", jobExecutionId,
|
||||
stepName);
|
||||
|
||||
@@ -12,17 +12,25 @@ import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
public class ErrorLogTasklet implements Tasklet, StepExecutionListener {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
private SimpleJdbcTemplate simpleJdbcTemplate;
|
||||
|
||||
|
||||
private String jobName;
|
||||
private String stepName;
|
||||
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
this.simpleJdbcTemplate.update("insert into ERROR_LOG values (?, ?, 'Some records were skipped!')", jobName, stepName);
|
||||
Assert.notNull(this.stepName, "Step name not set. Either this class was not registered as a listener "
|
||||
+ "or the key 'stepName' was not found in the Job's ExecutionContext.");
|
||||
this.simpleJdbcTemplate.update("insert into ERROR_LOG values (?, ?, 'Some records were skipped!')", jobName,
|
||||
stepName);
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
|
||||
@@ -30,12 +38,14 @@ public class ErrorLogTasklet implements Tasklet, StepExecutionListener {
|
||||
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
this.jobName = stepExecution.getJobExecution().getJobInstance().getJobName().trim();
|
||||
this.stepName = (String) stepExecution.getJobExecution().getExecutionContext().get("stepName");
|
||||
stepExecution.getJobExecution().getExecutionContext().remove("stepName");
|
||||
}
|
||||
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
this.jobName = stepExecution.getJobExecution().getJobInstance().getJobName().trim();
|
||||
this.stepName = (String)stepExecution.getJobExecution().getExecutionContext().get("stepName");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user