BATCH-1129: move <no-rollback-*/> up to <step/> in schema.

This commit is contained in:
dsyer
2009-03-20 15:01:11 +00:00
parent 0944d9a544
commit a8a6f27e83
6 changed files with 97 additions and 86 deletions

View File

@@ -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)) {

View File

@@ -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);

View File

@@ -289,6 +289,23 @@
<xsd:choice>
<xsd:element name="tasklet" type="taskletType" />
<xsd:element name="transaction-attributes" type="transaction-attributesType" />
<xsd:element name="no-rollback-exception-classes" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation><![CDATA[
List of exception classes that should not cause rollback if possible. This list
is only a hint and has to be interpreted by the step to make sense in context.
Separate each attribute with a comma or a newline.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attributeGroup ref="mergeAttribute" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="listeners" type="stepListenersType" />
</xsd:choice>
</xsd:group>
@@ -386,24 +403,8 @@
<xsd:element name="skippable-exception-classes" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation><![CDATA[
List of exception classes that are skippable.
Separate each attribute with a comma or a newline.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attributeGroup ref="mergeAttribute" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="no-rollback-exception-classes" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation><![CDATA[
List of exception classes that should not cause rollback if possible. This list
is only a hint and has to be interpreted by the step to make sense in context.
List of exception classes that are skippable. Exceptions that are already marked as no-rollback
are automatically skippable (but it doesn't hurt to add them again here).
Separate each attribute with a comma or a newline.
]]>
</xsd:documentation>