diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletElementParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletElementParser.java
index 94749f701..e65eb5d68 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletElementParser.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletElementParser.java
@@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.xml;
import java.util.ArrayList;
import java.util.List;
+import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanReference;
import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -77,56 +78,70 @@ public class TaskletElementParser {
else {
bd = new RootBeanDefinition("org.springframework.batch.core.step.item.SimpleStepFactoryBean", null, null);
}
+
+ MutablePropertyValues propertyValues = bd.getPropertyValues();
String readerBeanId = element.getAttribute("reader");
if (StringUtils.hasText(readerBeanId)) {
RuntimeBeanReference readerRef = new RuntimeBeanReference(readerBeanId);
- bd.getPropertyValues().addPropertyValue("itemReader", readerRef);
+ propertyValues.addPropertyValue("itemReader", readerRef);
}
String processorBeanId = element.getAttribute("processor");
if (StringUtils.hasText(processorBeanId)) {
RuntimeBeanReference processorRef = new RuntimeBeanReference(processorBeanId);
- bd.getPropertyValues().addPropertyValue("itemProcessor", processorRef);
+ propertyValues.addPropertyValue("itemProcessor", processorRef);
}
String writerBeanId = element.getAttribute("writer");
if (StringUtils.hasText(writerBeanId)) {
RuntimeBeanReference writerRef = new RuntimeBeanReference(writerBeanId);
- bd.getPropertyValues().addPropertyValue("itemWriter", writerRef);
+ propertyValues.addPropertyValue("itemWriter", writerRef);
}
String taskExecutorBeanId = element.getAttribute("task-executor");
if (StringUtils.hasText(taskExecutorBeanId)) {
RuntimeBeanReference taskExecutorRef = new RuntimeBeanReference(taskExecutorBeanId);
- bd.getPropertyValues().addPropertyValue("taskExecutor", taskExecutorRef);
+ propertyValues.addPropertyValue("taskExecutor", taskExecutorRef);
}
String commitInterval = element.getAttribute("commit-interval");
if (StringUtils.hasText(commitInterval)) {
- bd.getPropertyValues().addPropertyValue("commitInterval", commitInterval);
+ propertyValues.addPropertyValue("commitInterval", commitInterval);
}
- if (StringUtils.hasText(skipLimit)) {
- bd.getPropertyValues().addPropertyValue("skipLimit", skipLimit);
+ String completionPolicyRef = element.getAttribute("chunk-completion-policy");
+ if (StringUtils.hasText(completionPolicyRef)) {
+ RuntimeBeanReference completionPolicy = new RuntimeBeanReference(completionPolicyRef);
+ propertyValues.addPropertyValue("chunkCompletionPolicy", completionPolicy);
+ }
+
+ if (propertyValues.contains("commitInterval") == propertyValues.contains("chunkCompletionPolicy")) {
+ parserContext.getReaderContext().error(
+ "The 'tasklet' element must contain either 'commit-interval' "
+ + "or 'chunk-completion-policy', but not both.", element);
+ }
+
+ if (StringUtils.hasText(skipLimit)) {
+ propertyValues.addPropertyValue("skipLimit", skipLimit);
}
if (StringUtils.hasText(retryLimit)) {
- bd.getPropertyValues().addPropertyValue("retryLimit", retryLimit);
+ propertyValues.addPropertyValue("retryLimit", retryLimit);
}
if (StringUtils.hasText(cacheCapacity)) {
- bd.getPropertyValues().addPropertyValue("cacheCapacity", cacheCapacity);
+ propertyValues.addPropertyValue("cacheCapacity", cacheCapacity);
}
String transactionAttribute = element.getAttribute("transaction-attribute");
if (StringUtils.hasText(transactionAttribute)) {
- bd.getPropertyValues().addPropertyValue("transactionAttribute", transactionAttribute);
+ propertyValues.addPropertyValue("transactionAttribute", transactionAttribute);
}
if (StringUtils.hasText(isReaderTransactionalQueue)) {
if (isFaultTolerant) {
- bd.getPropertyValues().addPropertyValue("isReaderTransactionalQueue", isReaderTransactionalQueue);
+ propertyValues.addPropertyValue("isReaderTransactionalQueue", isReaderTransactionalQueue);
}
}
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
index ae0c3f1c8..47dcf5111 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
@@ -356,10 +356,11 @@
-
+
@@ -437,7 +438,7 @@
@@ -447,6 +448,22 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java
new file mode 100644
index 000000000..b9c6e0045
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java
@@ -0,0 +1,33 @@
+package org.springframework.batch.core.configuration.xml;
+
+import org.springframework.batch.repeat.CompletionPolicy;
+import org.springframework.batch.repeat.RepeatContext;
+import org.springframework.batch.repeat.RepeatStatus;
+
+/**
+ * @author Dan Garrette
+ * @since 2.0
+ */
+public class DummyCompletionPolicy implements CompletionPolicy {
+
+ public boolean isComplete(RepeatContext context, RepeatStatus result) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isComplete(RepeatContext context) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public RepeatContext start(RepeatContext parent) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void update(RepeatContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java
new file mode 100644
index 000000000..655ace386
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java
@@ -0,0 +1,17 @@
+package org.springframework.batch.core.configuration.xml;
+
+import org.springframework.batch.item.ItemReader;
+import org.springframework.batch.item.ParseException;
+import org.springframework.batch.item.UnexpectedInputException;
+
+/**
+ * @author Dan Garrette
+ * @since 2.0
+ */
+public class DummyItemReader implements ItemReader