BATCH-1163: In Batch xsd, elements in <job/> should be unordered

This commit is contained in:
dhgarrette
2009-03-20 07:07:09 +00:00
parent b72b7ae14d
commit dc71fe4431
4 changed files with 63 additions and 60 deletions

View File

@@ -75,7 +75,8 @@ public abstract class AbstractStepParser {
bd = taskletElementParser.parse(taskElement, parserContext, stepUnderspecified);
}
else if (taskletElements.size() > 1) {
parserContext.getReaderContext().error("The 'tasklet' element may not appear more than once.", stepElement);
parserContext.getReaderContext().error(
"The 'tasklet' element may not appear more than once in a single <step/>.", stepElement);
}
if (bd != null) {
@@ -141,7 +142,8 @@ public abstract class AbstractStepParser {
}
else if (txAttrElements.size() > 1) {
parserContext.getReaderContext().error(
"The 'transaction-attribute' element may not appear more than once.", stepElement);
"The 'transaction-attribute' element may not appear more than once in a single <step/>.",
stepElement);
}
handleListenersElement(stepElement, bd, parserContext);
@@ -187,7 +189,7 @@ public abstract class AbstractStepParser {
parserContext.popAndRegisterContainingComponent();
}
else if (listenersElements.size() > 1) {
parserContext.getReaderContext().error("The 'listeners' element may not appear more than once.",
parserContext.getReaderContext().error("The 'listeners' element may not appear more than once in a single <step/>.",
stepElement);
}
}

View File

@@ -90,8 +90,9 @@ public class JobParser extends AbstractSingleBeanDefinitionParser {
builder.addPropertyValue("flow", flowDef);
JobExecutionListenerParser listenerParser = new JobExecutionListenerParser();
Element listenersElement = (Element) DomUtils.getChildElementByTagName(element, "listeners");
if (listenersElement != null) {
List<Element> listenersElements = DomUtils.getChildElementsByTagName(element, "listeners");
if (listenersElements.size() == 1) {
Element listenersElement = listenersElements.get(0);
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(listenersElement.getTagName(),
parserContext.extractSource(element));
parserContext.pushContainingComponent(compositeDef);
@@ -105,7 +106,11 @@ public class JobParser extends AbstractSingleBeanDefinitionParser {
builder.addPropertyValue("jobExecutionListeners", listeners);
parserContext.popAndRegisterContainingComponent();
}
else if (listenersElements.size() > 1) {
parserContext.getReaderContext().error(
"The 'listeners' element may not appear more than once in a single <job/>.", element);
}
}
}

View File

@@ -23,37 +23,49 @@
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="flowType">
<xsd:group ref="jobListeners" />
<xsd:attribute name="id" type="xsd:ID" use="required" />
<xsd:attributeGroup ref="jobRepositoryAttribute" />
<xsd:attribute name="incrementer" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference to a JobParametersIncrementer bean definition. This will be
used to provide new parameters to a Job instance that is starting in a
sequence.
]]>
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref" />
<tool:expected-type type="org.springframework.batch.core.JobParametersIncrementer" />
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="restartable" type="xsd:string" default="true" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Whether the job should be retartable or not in case of failure. Set this to false
if the Job should not be restarted.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attributeGroup ref="parentAttribute" />
<xsd:attributeGroup ref="abstractAttribute" />
</xsd:extension>
</xsd:complexContent>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:group ref="flowGroup"/>
<xsd:element name="listeners">
<xsd:annotation>
<xsd:documentation><![CDATA[
List of all listeners for the job
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="listener" type="jobExecutionListenerType" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attributeGroup ref="mergeAttribute" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
<xsd:attribute name="id" type="xsd:ID" use="required" />
<xsd:attributeGroup ref="jobRepositoryAttribute" />
<xsd:attribute name="incrementer" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference to a JobParametersIncrementer bean definition. This will be
used to provide new parameters to a Job instance that is starting in a
sequence.
]]>
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref" />
<tool:expected-type type="org.springframework.batch.core.JobParametersIncrementer" />
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="restartable" type="xsd:string" default="true" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
Whether the job should be retartable or not in case of failure. Set this to false
if the Job should not be restarted.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attributeGroup ref="parentAttribute" />
<xsd:attributeGroup ref="abstractAttribute" />
</xsd:complexType>
</xsd:element>
@@ -159,8 +171,8 @@
</xsd:complexType>
</xsd:element>
<xsd:complexType name="flowType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:group name="flowGroup">
<xsd:choice>
<xsd:element name="step">
<xsd:annotation>
<xsd:documentation>
@@ -201,12 +213,15 @@
<xsd:complexContent>
<xsd:extension base="nextType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="flow" type="flowType">
<xsd:element name="flow">
<xsd:annotation>
<xsd:documentation>
A subflow within a job, having the same format as a job, but without a separate identity.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:group ref="flowGroup" minOccurs="0" maxOccurs="unbounded"/>
</xsd:complexType>
</xsd:element>
<xsd:group ref="transitions"/>
</xsd:choice>
@@ -252,25 +267,6 @@
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
<xsd:group name="jobListeners">
<xsd:sequence>
<xsd:element name="listeners" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation><![CDATA[
List of all listeners for the job
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="listener" type="jobExecutionListenerType" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attributeGroup ref="mergeAttribute" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:group>
<xsd:complexType name="stepType">

View File

@@ -22,7 +22,7 @@
<next on="COMPLETED WITH SKIPS" to="errorPrint1" />
<fail on="FAILED" exit-code="FAILED"/>
</step>
<step id="errorPrint1" tasklet="errorLogTasklet" next="step2"/>
<step id="step2" ref="secondPass" next="skipCheckingDecision"/>