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:
@@ -18,11 +18,13 @@ package org.springframework.batch.core.configuration.xml;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.ManagedMap;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
@@ -55,7 +57,8 @@ public abstract class AbstractStepParser {
|
||||
*/
|
||||
protected AbstractBeanDefinition parseTaskletRef(Element stepElement, String taskletRef, ParserContext parserContext, String jobRepositoryRef) {
|
||||
|
||||
RootBeanDefinition bd = new RootBeanDefinition("org.springframework.batch.core.step.tasklet.TaskletStep", null, null);
|
||||
GenericBeanDefinition bd = new GenericBeanDefinition();
|
||||
bd.setBeanClass(TaskletStep.class);
|
||||
|
||||
if (StringUtils.hasText(taskletRef)) {
|
||||
RuntimeBeanReference taskletBeanRef = new RuntimeBeanReference(taskletRef);
|
||||
@@ -117,6 +120,10 @@ public abstract class AbstractStepParser {
|
||||
String allowStartIfComplete = stepElement.getAttribute("allow-start-if-complete");
|
||||
if (StringUtils.hasText(allowStartIfComplete)) {
|
||||
bd.getPropertyValues().addPropertyValue("allowStartIfComplete", allowStartIfComplete);
|
||||
}
|
||||
String parentRef = stepElement.getAttribute("parent");
|
||||
if (StringUtils.hasText(parentRef)) {
|
||||
bd.setParentName(parentRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,9 @@ public class InlineStepParser extends AbstractStepParser {
|
||||
if (listOfListenersElements.size() > 0) {
|
||||
parserContext.getReaderContext().error("The 'listeners' element can't be combined with the 'ref=\""+ stepRef +"\"' attribute specification for <" + element.getNodeName() + ">", element);
|
||||
}
|
||||
if (StringUtils.hasText(element.getAttribute("parent"))) {
|
||||
parserContext.getReaderContext().error("The 'parent' element can't be combined with the 'ref=\""+ stepRef +"\"' attribute specification for <" + element.getNodeName() + ">", element);
|
||||
}
|
||||
BeanDefinitionBuilder stepBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition("org.springframework.batch.core.configuration.xml.DelegatingStep");
|
||||
stepBuilder.addConstructorArgValue(stepId);
|
||||
|
||||
@@ -54,6 +54,7 @@ public class StandaloneStepParser extends AbstractStepParser {
|
||||
Element taskElement = processTaskElements.get(0);
|
||||
bd = parseTaskletElement(element, taskElement, parserContext, jobRepositoryRef);
|
||||
}
|
||||
bd.setAbstract(Boolean.valueOf(element.getAttribute("abstract")));
|
||||
|
||||
return bd;
|
||||
|
||||
|
||||
@@ -18,12 +18,15 @@ package org.springframework.batch.core.configuration.xml;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean;
|
||||
import org.springframework.batch.core.step.item.SimpleStepFactoryBean;
|
||||
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;
|
||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
@@ -46,8 +49,6 @@ public class TaskletElementParser {
|
||||
*/
|
||||
protected AbstractBeanDefinition parseTaskletElement(Element element, ParserContext parserContext) {
|
||||
|
||||
RootBeanDefinition bd;
|
||||
|
||||
boolean isFaultTolerant = false;
|
||||
|
||||
String skipLimit = element.getAttribute("skip-limit");
|
||||
@@ -72,11 +73,12 @@ public class TaskletElementParser {
|
||||
checkExceptionElementForFaultToleranceNeeded(element, "retryable-exception-classes");
|
||||
checkExceptionElementForFaultToleranceNeeded(element, "fatal-exception-classes");
|
||||
|
||||
GenericBeanDefinition bd = new GenericBeanDefinition();
|
||||
if (isFaultTolerant) {
|
||||
bd = new RootBeanDefinition("org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean", null, null);
|
||||
bd.setBeanClass(FaultTolerantStepFactoryBean.class);
|
||||
}
|
||||
else {
|
||||
bd = new RootBeanDefinition("org.springframework.batch.core.step.item.SimpleStepFactoryBean", null, null);
|
||||
bd.setBeanClass(SimpleStepFactoryBean.class);
|
||||
}
|
||||
|
||||
MutablePropertyValues propertyValues = bd.getPropertyValues();
|
||||
|
||||
@@ -753,6 +753,9 @@
|
||||
<xsd:documentation>
|
||||
The name of the parent step from which the configuration should inherit.
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref"/>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:attributeGroup>
|
||||
|
||||
Reference in New Issue
Block a user