diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java
index 5a0f0cfac..8d33cb0b1 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java
@@ -52,6 +52,8 @@ public abstract class AbstractStepParser {
private static final String PARENT_ATTR = "parent";
private static final String REF_ATTR = "ref";
+
+ private static final String ALLOW_START_ATTR = "allow-start-if-complete";
private static final String TASKLET_ELE = "tasklet";
@@ -176,6 +178,16 @@ public abstract class AbstractStepParser {
bd.setAttribute("jobParserJobFactoryBeanRef", jobFactoryRef);
}
+ //add the allow parser here
+ String isAllowStart = stepElement.getAttribute(ALLOW_START_ATTR);
+ if (StringUtils.hasText(isAllowStart)) {
+ //check if the value is already set from an inner element
+ if (!bd.getPropertyValues().contains("allowStartIfComplete")) {
+ //set the value as a property
+ bd.getPropertyValues().add("allowStartIfComplete", Boolean.valueOf(isAllowStart));
+ }//end if
+ }
+
stepListenerParser.handleListenersElement(stepElement, bd, parserContext);
return bd;
}
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd
index 5bff17301..bb58e2cbb 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd
@@ -286,6 +286,7 @@ ref" is not required, and only needs to be specified explicitly
+
@@ -623,13 +624,6 @@ ref" is not required, and only needs to be specified explicitly
]]>
-
-
-
-
-
+
@@ -985,6 +980,16 @@ ref" is not required, and only needs to be specified explicitly
+
+
+
+
+
+
+
+
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java
new file mode 100644
index 000000000..a32354c4e
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java
@@ -0,0 +1,84 @@
+package org.springframework.batch.core.configuration.xml;
+
+<<<<<<< HEAD
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import javax.annotation.Resource;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobParametersBuilder;
+import org.springframework.batch.core.repository.JobRepository;
+import org.springframework.batch.core.step.AbstractStep;
+import org.springframework.beans.factory.annotation.Autowired;
+=======
+import static org.junit.Assert.assertTrue;
+
+import javax.annotation.Resource;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.batch.core.step.AbstractStep;
+>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+<<<<<<< HEAD
+=======
+//@Ignore
+>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class TaskletStepAllowStartIfCompleteTest {
+
+<<<<<<< HEAD
+ @Autowired
+ Job job;
+
+ @Autowired
+ JobRepository jobRepository;
+
+ @Resource
+ private ApplicationContext context;
+
+ @Test
+ public void test() throws Exception {
+ //retrieve the step from the context and see that it's allow is set
+ AbstractStep abstractStep = (AbstractStep) context.getBean("simpleJob.step1");
+ assertTrue(abstractStep.isAllowStartIfComplete());
+ }
+
+ @Test
+ public void testRestart() throws Exception {
+ JobParametersBuilder paramBuilder = new JobParametersBuilder();
+ paramBuilder.addDate("value", new Date());
+ JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters());
+
+ job.execute(jobExecution);
+
+ jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters());
+ job.execute(jobExecution);
+
+ int count = jobRepository.getStepExecutionCount(jobExecution.getJobInstance(), "simpleJob.step1");
+ assertEquals(2, count);
+ }
+=======
+ @Resource
+ private ApplicationContext context;
+
+ @Test
+ public void test() throws Exception {
+ //retrieve the step from the context and see that it's allow is set
+ AbstractStep abstractStep = context.getBean(AbstractStep.class);
+ assertTrue(abstractStep.isAllowStartIfComplete());
+ }
+
+>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72
+}
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml
new file mode 100644
index 000000000..a3aa712fe
--- /dev/null
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+<<<<<<< HEAD
+
+=======
+
+>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72
+
+
+
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+
+
+
+
+
+
+
+
+
+
+=======
+>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+=======
+
+>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72
+
+
+