From dc71fe443167122e80f741a2ea9b4506fa51fd9e Mon Sep 17 00:00:00 2001 From: dhgarrette Date: Fri, 20 Mar 2009 07:07:09 +0000 Subject: [PATCH] BATCH-1163: In Batch xsd, elements in should be unordered --- .../configuration/xml/AbstractStepParser.java | 8 +- .../core/configuration/xml/JobParser.java | 11 +- .../configuration/xml/spring-batch-2.0.xsd | 102 +++++++++--------- .../src/main/resources/jobs/skipSampleJob.xml | 2 +- 4 files changed, 63 insertions(+), 60 deletions(-) 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 e40e9322e..2af1f52d4 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 @@ -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 .", 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 .", + 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 .", stepElement); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java index 3d8a85070..748eb689d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java @@ -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 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 .", element); + } + } } 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 fee9b975b..8324d393b 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 @@ -23,37 +23,49 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -159,8 +171,8 @@ - - + + @@ -201,12 +213,15 @@ - + A subflow within a job, having the same format as a job, but without a separate identity. + + + @@ -252,25 +267,6 @@ - - - - - - - - - - - - - - - - - diff --git a/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml index d4776c5bb..28a54e496 100644 --- a/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml @@ -22,7 +22,7 @@ - +