From a8a6f27e83c50ea80e8937511286f91456cb3bbe Mon Sep 17 00:00:00 2001 From: dsyer Date: Fri, 20 Mar 2009 15:01:11 +0000 Subject: [PATCH] BATCH-1129: move up to in schema. --- .../configuration/xml/AbstractStepParser.java | 21 +++++++++ .../xml/TaskletElementParser.java | 2 - .../configuration/xml/spring-batch-2.0.xsd | 37 ++++++++------- ...tepParserBadRetryListenerTests-context.xml | 39 +++++++-------- ...epParserTaskletAttributesTests-context.xml | 37 +++++++-------- ...erantProcessTaskJobParserTests-context.xml | 47 +++++++++---------- 6 files changed, 97 insertions(+), 86 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 37b0d3c31..38b075b9d 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 @@ -15,6 +15,7 @@ */ package org.springframework.batch.core.configuration.xml; +import java.util.Arrays; import java.util.List; import org.springframework.beans.factory.config.BeanDefinition; @@ -148,6 +149,8 @@ public abstract class AbstractStepParser { } handleListenersElement(stepElement, bd, parserContext); + + handleExceptionElement(stepElement, parserContext, bd, "no-rollback-exception-classes", "noRollbackExceptionClasses"); bd.setRole(BeanDefinition.ROLE_SUPPORT); @@ -155,6 +158,24 @@ public abstract class AbstractStepParser { } + @SuppressWarnings("unchecked") + private void handleExceptionElement(Element element, ParserContext parserContext, BeanDefinition bd, + String subElementName, String propertyName) { + Element child = DomUtils.getChildElementByTagName(element, subElementName); + if (child != null) { + String exceptions = DomUtils.getTextValue(child); + if (StringUtils.hasLength(exceptions)) { + String[] exceptionArray = StringUtils.tokenizeToStringArray(exceptions, ",\n"); + if (exceptionArray.length > 0) { + ManagedList managedList = new ManagedList(); + managedList.setMergeEnabled(Boolean.valueOf(child.getAttribute("merge"))); + managedList.addAll(Arrays.asList(exceptionArray)); + bd.getPropertyValues().addPropertyValue(propertyName, managedList); + } + } + } + } + private void checkStepAttributes(Element stepElement, AbstractBeanDefinition bd) { String startLimit = stepElement.getAttribute("start-limit"); if (StringUtils.hasText(startLimit)) { 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 92a728dc5..96ec46510 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 @@ -123,8 +123,6 @@ public class TaskletElementParser { handleExceptionElement(element, parserContext, bd, "fatal-exception-classes", "fatalExceptionClasses"); - handleExceptionElement(element, parserContext, bd, "no-rollback-exception-classes", "noRollbackExceptionClasses"); - handleRetryListenersElement(element, bd, parserContext); handleStreamsElement(element, bd, parserContext); 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 f024c7619..f79f7ec78 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 @@ -289,6 +289,23 @@ + + + + + + + + + + + + + @@ -386,24 +403,8 @@ - - - - - - - - - - - - - diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserBadRetryListenerTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserBadRetryListenerTests-context.xml index e946d8aa4..b477a3d73 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserBadRetryListenerTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserBadRetryListenerTests-context.xml @@ -5,44 +5,41 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + - + - + - + org.springframework.dao.DataIntegrityViolationException, - + + + org.springframework.dao.DataIntegrityViolationException - - - + - - - - - + - + - - - + + + + + + + \ No newline at end of file diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml index 11a08afa2..feb249ed1 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml @@ -6,16 +6,13 @@ - + - + - + org.springframework.jdbc.BadSqlGrammarException @@ -23,26 +20,26 @@ org.springframework.dao.DataIntegrityViolationException - - org.springframework.dao.DataIntegrityViolationException - - + + + org.springframework.dao.DataIntegrityViolationException + - + - - - - - + - - - + + + + + + + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithFaultTolerantProcessTaskJobParserTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithFaultTolerantProcessTaskJobParserTests-context.xml index c9ae78b46..f96cce0a6 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithFaultTolerantProcessTaskJobParserTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithFaultTolerantProcessTaskJobParserTests-context.xml @@ -5,46 +5,43 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + - + - - + + - + org.springframework.dao.DataIntegrityViolationException - - org.springframework.dao.DataIntegrityViolationException - - + + + org.springframework.dao.DataIntegrityViolationException + - - + + - - - - - + - - - - - + + + + + + + + + \ No newline at end of file