BATCH-1160: In Batch xsd, stepType and flowStepType should be unordered
This commit is contained in:
@@ -59,11 +59,10 @@ public abstract class AbstractStepParser {
|
||||
String taskletRef = stepElement.getAttribute("tasklet");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Element> taskletElements = (List<Element>) DomUtils.getChildElementsByTagName(stepElement, "tasklet");
|
||||
boolean taskletElementExists = taskletElements.size() > 0;
|
||||
boolean stepUnderspecified = CoreNamespaceUtils.isUnderspecified(stepElement);
|
||||
AbstractBeanDefinition bd = null;
|
||||
if (StringUtils.hasText(taskletRef)) {
|
||||
if (taskletElementExists) {
|
||||
if (taskletElements.size() > 0) {
|
||||
parserContext.getReaderContext().error(
|
||||
"The <" + taskletElements.get(0).getNodeName()
|
||||
+ "> element can't be combined with the 'tasklet=\"" + taskletRef
|
||||
@@ -71,10 +70,13 @@ public abstract class AbstractStepParser {
|
||||
}
|
||||
bd = parseTaskletRef(stepElement, taskletRef, parserContext, jobRepositoryRef);
|
||||
}
|
||||
else if (taskletElementExists) {
|
||||
else if (taskletElements.size() == 1) {
|
||||
Element taskElement = taskletElements.get(0);
|
||||
bd = taskletElementParser.parse(taskElement, parserContext, stepUnderspecified);
|
||||
}
|
||||
else if (taskletElements.size() > 1) {
|
||||
parserContext.getReaderContext().error("The 'tasklet' element may not appear more than once.", stepElement);
|
||||
}
|
||||
|
||||
if (bd != null) {
|
||||
setUpBeanDefinition(stepElement, bd, parserContext, jobRepositoryRef);
|
||||
@@ -123,19 +125,24 @@ public abstract class AbstractStepParser {
|
||||
RuntimeBeanReference transactionManagerBeanRef = new RuntimeBeanReference(transactionManagerRef);
|
||||
bd.getPropertyValues().addPropertyValue("transactionManager", transactionManagerBeanRef);
|
||||
|
||||
Element child = DomUtils.getChildElementByTagName(stepElement, "transaction-attributes");
|
||||
if (child != null) {
|
||||
String attributes = DomUtils.getTextValue(child);
|
||||
List<Element> txAttrElements = DomUtils.getChildElementsByTagName(stepElement, "transaction-attributes");
|
||||
if (txAttrElements.size() == 1) {
|
||||
Element txAttrElement = txAttrElements.get(0);
|
||||
String attributes = DomUtils.getTextValue(txAttrElement);
|
||||
if (StringUtils.hasLength(attributes)) {
|
||||
String[] attributesArray = StringUtils.tokenizeToStringArray(attributes, ",\n");
|
||||
if (attributesArray.length > 0) {
|
||||
ManagedList managedList = new ManagedList();
|
||||
managedList.setMergeEnabled(Boolean.valueOf(child.getAttribute("merge")));
|
||||
managedList.setMergeEnabled(Boolean.valueOf(txAttrElement.getAttribute("merge")));
|
||||
managedList.addAll(Arrays.asList(attributesArray));
|
||||
bd.getPropertyValues().addPropertyValue("transactionAttributeList", managedList);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (txAttrElements.size() > 1) {
|
||||
parserContext.getReaderContext().error(
|
||||
"The 'transaction-attribute' element may not appear more than once.", stepElement);
|
||||
}
|
||||
|
||||
handleListenersElement(stepElement, bd, parserContext);
|
||||
|
||||
@@ -161,11 +168,12 @@ public abstract class AbstractStepParser {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void handleListenersElement(Element element, BeanDefinition bd, ParserContext parserContext) {
|
||||
Element listenersElement = DomUtils.getChildElementByTagName(element, "listeners");
|
||||
if (listenersElement != null) {
|
||||
private void handleListenersElement(Element stepElement, BeanDefinition bd, ParserContext parserContext) {
|
||||
List<Element> listenersElements = DomUtils.getChildElementsByTagName(stepElement, "listeners");
|
||||
if (listenersElements.size() == 1) {
|
||||
Element listenersElement = listenersElements.get(0);
|
||||
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(listenersElement.getTagName(),
|
||||
parserContext.extractSource(element));
|
||||
parserContext.extractSource(stepElement));
|
||||
parserContext.pushContainingComponent(compositeDef);
|
||||
ManagedList listenerBeans = new ManagedList();
|
||||
listenerBeans.setMergeEnabled(Boolean.valueOf(listenersElement.getAttribute("merge")));
|
||||
@@ -178,6 +186,10 @@ public abstract class AbstractStepParser {
|
||||
bd.getPropertyValues().addPropertyValue("listeners", listenerBeans);
|
||||
parserContext.popAndRegisterContainingComponent();
|
||||
}
|
||||
else if (listenersElements.size() > 1) {
|
||||
parserContext.getReaderContext().error("The 'listeners' element may not appear more than once.",
|
||||
stepElement);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -276,11 +276,11 @@
|
||||
</xsd:group>
|
||||
|
||||
<xsd:complexType name="stepType">
|
||||
<xsd:sequence>
|
||||
<xsd:choice minOccurs="0" maxOccurs="3">
|
||||
<xsd:element name="tasklet" type="taskletType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="transaction-attributes" type="transaction-attributesType" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="listeners" type="stepListenersType" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:element name="listeners" type="stepListenersType" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:choice>
|
||||
<xsd:attributeGroup ref="transactionManagerAttribute" />
|
||||
</xsd:complexType>
|
||||
|
||||
@@ -288,16 +288,18 @@
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="nextType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="tasklet" type="taskletType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="transaction-attributes" type="transaction-attributesType" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="listeners" type="stepListenersType" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:choice minOccurs="0" maxOccurs="3">
|
||||
<xsd:element name="tasklet" type="taskletType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="transaction-attributes" type="transaction-attributesType" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="listeners" type="stepListenersType" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:choice>
|
||||
<xsd:group ref="transitions"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attributeGroup ref="transactionManagerAttribute" />
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
|
||||
<xsd:complexType name="taskletType">
|
||||
<xsd:all>
|
||||
<xsd:element name="retry-listeners" minOccurs="0" maxOccurs="1">
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
</job>
|
||||
|
||||
<step id="secondPass" parent="t2">
|
||||
<transaction-attributes/>
|
||||
<tasklet writer="itemTrackingWriter">
|
||||
<skippable-exception-classes merge="true">
|
||||
java.lang.RuntimeException
|
||||
|
||||
Reference in New Issue
Block a user