From 190b14b3fdcc31499a85584c691d200eb40a5a4f Mon Sep 17 00:00:00 2001 From: trisberg Date: Fri, 21 Nov 2008 03:23:51 +0000 Subject: [PATCH] BATCH-63: added element to --- .../core/configuration/xml/StepParser.java | 66 ++++++++++--------- .../configuration/xml/spring-batch-2.0.xsd | 15 +++++ .../xml/StepWithSimpleTaskJobParserTests.java | 7 ++ ...epWithSimpleTaskJobParserTests-context.xml | 6 +- 4 files changed, 61 insertions(+), 33 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java index 733f5f8a6..01ae1ad2b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java @@ -191,6 +191,37 @@ public class StepParser { } + /** + * @param element + * @param parserContext + * @return the TaskletStep bean + */ + protected RootBeanDefinition parseSimpleTask(Element element, ParserContext parserContext) { + + RootBeanDefinition bd = new RootBeanDefinition("org.springframework.batch.core.step.tasklet.TaskletStep", null, null); + + String taskletBeanId = element.getAttribute("tasklet"); + if (StringUtils.hasText(taskletBeanId)) { + RuntimeBeanReference taskletRef = new RuntimeBeanReference(taskletBeanId); + bd.getPropertyValues().addPropertyValue("tasklet", taskletRef); + } + + String jobRepository = element.getAttribute("job-repository"); + RuntimeBeanReference jobRepositoryRef = new RuntimeBeanReference(jobRepository); + bd.getPropertyValues().addPropertyValue("jobRepository", jobRepositoryRef); + + String transactionManager = element.getAttribute("transaction-manager"); + RuntimeBeanReference tx = new RuntimeBeanReference(transactionManager); + bd.getPropertyValues().addPropertyValue("transactionManager", tx); + + handleListenersElement(element, bd, parserContext, "stepExecutionListeners"); + + bd.setRole(BeanDefinition.ROLE_SUPPORT); + + return bd; + + } + /** * @param element * @param parserContext @@ -301,7 +332,7 @@ public class StepParser { handleExceptionElement(element, bd, "fatal-exception-classes", "fatalExceptionClasses", isFaultTolerant); - handleListenersElement(element, bd, parserContext); + handleListenersElement(element, bd, parserContext, "listeners"); handleRetryListenersElement(element, bd, parserContext); @@ -352,7 +383,7 @@ public class StepParser { } @SuppressWarnings("unchecked") - private void handleListenersElement(Element element, RootBeanDefinition bd, ParserContext parserContext) { + private void handleListenersElement(Element element, RootBeanDefinition bd, ParserContext parserContext, String property) { Element listenersElement = DomUtils.getChildElementByTagName(element, "listeners"); if (listenersElement != null) { @@ -361,7 +392,7 @@ public class StepParser { listenerBeans); ManagedList arguments = new ManagedList(); arguments.addAll(listenerBeans); - bd.getPropertyValues().addPropertyValue("listeners", arguments); + bd.getPropertyValues().addPropertyValue(property, arguments); } } @@ -448,33 +479,4 @@ public class StepParser { } } - /** - * @param element - * @param parserContext - * @return the TaskletStep bean - */ - protected RootBeanDefinition parseSimpleTask(Element element, ParserContext parserContext) { - - RootBeanDefinition bd = new RootBeanDefinition("org.springframework.batch.core.step.tasklet.TaskletStep", null, null); - - String taskletBeanId = element.getAttribute("tasklet"); - if (StringUtils.hasText(taskletBeanId)) { - RuntimeBeanReference taskletRef = new RuntimeBeanReference(taskletBeanId); - bd.getPropertyValues().addPropertyValue("tasklet", taskletRef); - } - - String jobRepository = element.getAttribute("job-repository"); - RuntimeBeanReference jobRepositoryRef = new RuntimeBeanReference(jobRepository); - bd.getPropertyValues().addPropertyValue("jobRepository", jobRepositoryRef); - - String transactionManager = element.getAttribute("transaction-manager"); - RuntimeBeanReference tx = new RuntimeBeanReference(transactionManager); - bd.getPropertyValues().addPropertyValue("transactionManager", tx); - - bd.setRole(BeanDefinition.ROLE_SUPPORT); - - return bd; - - } - } 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 e0143d12d..193d5ac2b 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 @@ -232,6 +232,21 @@ + + + + + + + + + + + + + - + + + + +