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>

View File

@@ -5,44 +5,41 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<beans:import resource="common-context.xml" />
<job id="job">
<step id="step">
<tasklet reader="reader" processor="processor" writer="writer"
commit-interval="10" skip-limit="20"
retry-limit="3" cache-capacity="100"
is-reader-transactional-queue="true"
task-executor="taskExecutor">
<tasklet reader="reader" processor="processor" writer="writer" commit-interval="10" skip-limit="20"
retry-limit="3" cache-capacity="100" is-reader-transactional-queue="true" task-executor="taskExecutor">
<retry-listeners>
<listener class="org.springframework.batch.core.configuration.xml.TestRetryListener" ref="retryListener"/>
<listener class="org.springframework.batch.core.configuration.xml.TestRetryListener" ref="retryListener" />
</retry-listeners>
<streams>
<stream ref="reader"/>
<stream ref="reader" />
</streams>
<skippable-exception-classes>
org.springframework.dao.DataIntegrityViolationException,
</skippable-exception-classes>
<no-rollback-exception-classes>
</tasklet>
<transaction-attributes propagation="REQUIRED" isolation="DEFAULT" timeout="10" />
<no-rollback-exception-classes>
org.springframework.dao.DataIntegrityViolationException
</no-rollback-exception-classes>
</tasklet>
<transaction-attributes propagation="REQUIRED" isolation="DEFAULT" timeout="10"/>
<listeners>
<listener ref="listener"/>
<listener ref="listener" />
</listeners>
</step>
</job>
<beans:bean id="reader" class="org.springframework.batch.core.configuration.xml.TestReader"/>
<beans:bean id="processor" class="org.springframework.batch.core.configuration.xml.TestProcessor"/>
<beans:bean id="writer" class="org.springframework.batch.core.configuration.xml.TestWriter"/>
<beans:bean id="reader" class="org.springframework.batch.core.configuration.xml.TestReader" />
<beans:bean id="listener" class="org.springframework.batch.core.configuration.xml.TestListener"/>
<beans:bean id="processor" class="org.springframework.batch.core.configuration.xml.TestProcessor" />
<beans:bean id="retryListener" class="org.springframework.batch.core.configuration.xml.TestRetryListener"/>
<beans:bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor"/>
<beans:bean id="writer" class="org.springframework.batch.core.configuration.xml.TestWriter" />
<beans:bean id="listener" class="org.springframework.batch.core.configuration.xml.TestListener" />
<beans:bean id="retryListener" class="org.springframework.batch.core.configuration.xml.TestRetryListener" />
<beans:bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor" />
</beans:beans>

View File

@@ -6,16 +6,13 @@
<job id="job">
<step id="step" start-limit="25" allow-start-if-complete="true">
<tasklet reader="reader" processor="processor" writer="writer"
commit-interval="10" skip-limit="20"
retry-limit="3" cache-capacity="100"
is-reader-transactional-queue="true"
task-executor="taskExecutor">
<tasklet reader="reader" processor="processor" writer="writer" commit-interval="10" skip-limit="20"
retry-limit="3" cache-capacity="100" is-reader-transactional-queue="true" task-executor="taskExecutor">
<retry-listeners>
<listener class="org.springframework.batch.core.configuration.xml.TestRetryListener"/>
<listener class="org.springframework.batch.core.configuration.xml.TestRetryListener" />
</retry-listeners>
<streams>
<stream ref="reader"/>
<stream ref="reader" />
</streams>
<fatal-exception-classes>
org.springframework.jdbc.BadSqlGrammarException
@@ -23,26 +20,26 @@
<skippable-exception-classes>
org.springframework.dao.DataIntegrityViolationException
</skippable-exception-classes>
<no-rollback-exception-classes>
org.springframework.dao.DataIntegrityViolationException
</no-rollback-exception-classes>
</tasklet>
<transaction-attributes propagation="REQUIRED" isolation="DEFAULT" timeout="10"/>
<transaction-attributes propagation="REQUIRED" isolation="DEFAULT" timeout="10" />
<no-rollback-exception-classes>
org.springframework.dao.DataIntegrityViolationException
</no-rollback-exception-classes>
<listeners>
<listener ref="listener"/>
<listener ref="listener" />
</listeners>
</step>
</job>
<beans:bean id="reader" class="org.springframework.batch.core.configuration.xml.TestReader"/>
<beans:bean id="processor" class="org.springframework.batch.core.configuration.xml.TestProcessor"/>
<beans:bean id="writer" class="org.springframework.batch.core.configuration.xml.TestWriter"/>
<beans:bean id="reader" class="org.springframework.batch.core.configuration.xml.TestReader" />
<beans:bean id="listener" class="org.springframework.batch.core.configuration.xml.TestListener"/>
<beans:bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor"/>
<beans:bean id="processor" class="org.springframework.batch.core.configuration.xml.TestProcessor" />
<beans:bean id="writer" class="org.springframework.batch.core.configuration.xml.TestWriter" />
<beans:bean id="listener" class="org.springframework.batch.core.configuration.xml.TestListener" />
<beans:bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor" />
<beans:bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />

View File

@@ -5,46 +5,43 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<beans:import resource="common-context.xml" />
<job id="job">
<step id="step">
<tasklet reader="reader" processor="processor" writer="writer"
commit-interval="10" skip-limit="20"
retry-limit="3" cache-capacity="100"
is-reader-transactional-queue="true"
task-executor="taskExecutor">
<tasklet reader="reader" processor="processor" writer="writer" commit-interval="10" skip-limit="20"
retry-limit="3" cache-capacity="100" is-reader-transactional-queue="true" task-executor="taskExecutor">
<retry-listeners>
<listener ref="retryListener"/>
<listener class="org.springframework.batch.core.configuration.xml.TestRetryListener"/>
<listener ref="retryListener" />
<listener class="org.springframework.batch.core.configuration.xml.TestRetryListener" />
</retry-listeners>
<streams>
<stream ref="reader"/>
<stream ref="reader" />
</streams>
<skippable-exception-classes>
org.springframework.dao.DataIntegrityViolationException
</skippable-exception-classes>
<no-rollback-exception-classes>
org.springframework.dao.DataIntegrityViolationException
</no-rollback-exception-classes>
</tasklet>
<transaction-attributes propagation="REQUIRED" isolation="DEFAULT" timeout="10"/>
<transaction-attributes propagation="REQUIRED" isolation="DEFAULT" timeout="10" />
<no-rollback-exception-classes>
org.springframework.dao.DataIntegrityViolationException
</no-rollback-exception-classes>
<listeners>
<listener class="org.springframework.batch.core.configuration.xml.TestListener"/>
<listener ref="listener"/>
<listener class="org.springframework.batch.core.configuration.xml.TestListener" />
<listener ref="listener" />
</listeners>
</step>
</job>
<beans:bean id="reader" class="org.springframework.batch.core.configuration.xml.TestReader"/>
<beans:bean id="processor" class="org.springframework.batch.core.configuration.xml.TestProcessor"/>
<beans:bean id="writer" class="org.springframework.batch.core.configuration.xml.TestWriter"/>
<beans:bean id="reader" class="org.springframework.batch.core.configuration.xml.TestReader" />
<beans:bean id="listener" class="org.springframework.batch.core.configuration.xml.TestListener"/>
<beans:bean id="retryListener" class="org.springframework.batch.core.configuration.xml.TestRetryListener"/>
<beans:bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor"/>
<beans:bean id="processor" class="org.springframework.batch.core.configuration.xml.TestProcessor" />
<beans:bean id="writer" class="org.springframework.batch.core.configuration.xml.TestWriter" />
<beans:bean id="listener" class="org.springframework.batch.core.configuration.xml.TestListener" />
<beans:bean id="retryListener" class="org.springframework.batch.core.configuration.xml.TestRetryListener" />
<beans:bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor" />
</beans:beans>