diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java index 489b4c4dc..8868443d0 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java @@ -293,7 +293,7 @@ public class StepParserStepFactoryBean implements FactoryBean, BeanNameAwa } /** - * @param builder + * @param builder {@link StepBuilderHelper} representing the step to be enhanced */ protected void enhanceCommonStep(StepBuilderHelper> builder) { if (allowStartIfComplete != null) { @@ -867,11 +867,8 @@ public class StepParserStepFactoryBean implements FactoryBean, BeanNameAwa jsrRetryListeners.add(new RetryWriteListenerAdapter((RetryWriteListener) listener)); } if(listener instanceof PartitionCollector) { - PartitionCollectorAdapter adapter = new PartitionCollectorAdapter(); - adapter.setPartitionCollector((PartitionCollector) listener); - adapter.setPartitionQueue(partitionQueue); + PartitionCollectorAdapter adapter = new PartitionCollectorAdapter(partitionQueue, (PartitionCollector) listener); chunkListeners.add(adapter); - stepExecutionListeners.add(adapter); } } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionException.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionException.java index 896fcb01e..daf69d167 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionException.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionException.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.batch.core.job.flow; * @author Dave Syer * */ +@SuppressWarnings("serial") public class FlowExecutionException extends Exception { /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/JsrAutowiredAnnotationBeanPostProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/JsrAutowiredAnnotationBeanPostProcessor.java index 27d6ba06e..ea55af716 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/JsrAutowiredAnnotationBeanPostProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/JsrAutowiredAnnotationBeanPostProcessor.java @@ -17,26 +17,28 @@ package org.springframework.batch.core.jsr.configuration.support; import java.lang.annotation.Annotation; import java.lang.reflect.AccessibleObject; + import javax.batch.api.BatchProperty; + import org.springframework.beans.factory.annotation.InjectionMetadata; /** *
This class overrides methods in the copied {@link SpringAutowiredAnnotationBeanPostProcessor} class - * to check for the {@link @BatchProperty} annotation before processing injection annotations. If the annotation + * to check for the {@link BatchProperty} annotation before processing injection annotations. If the annotation * is found, further injection processing for the field is skipped.
*/ public class JsrAutowiredAnnotationBeanPostProcessor extends SpringAutowiredAnnotationBeanPostProcessor { - @Override - protected InjectionMetadata findAutowiringMetadata(Class> clazz) { - return super.buildAutowiringMetadata(clazz); - } + @Override + protected InjectionMetadata findAutowiringMetadata(Class> clazz) { + return super.buildAutowiringMetadata(clazz); + } - @Override - protected Annotation findAutowiredAnnotation(AccessibleObject ao) { - if (ao.getAnnotation(BatchProperty.class) != null) { - return null; - } + @Override + protected Annotation findAutowiredAnnotation(AccessibleObject ao) { + if (ao.getAnnotation(BatchProperty.class) != null) { + return null; + } - return super.findAutowiredAnnotation(ao); - } + return super.findAutowiredAnnotation(ao); + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/PartitionParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/PartitionParser.java index c99749003..376a45c6e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/PartitionParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/PartitionParser.java @@ -75,32 +75,23 @@ public class PartitionParser { MutablePropertyValues properties = partitionHandlerDefinition.getPropertyValues(); properties.addPropertyValue(PARTITION_CONTEXT_PROPERTY, new RuntimeBeanReference("batchPropertyContext")); - Element mapperElement = DomUtils.getChildElementByTagName(element, MAPPER_ELEMENT); - - if(mapperElement != null) { - String mapperName = mapperElement.getAttribute(REF); - properties.add(PARTITION_MAPPER_PROPERTY, new RuntimeBeanReference(mapperName)); - new PropertyParser(mapperName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(mapperElement); - } - + paserMapperElement(element, parserContext, properties); parsePartitionPlan(element, parserContext, stepName, properties); + parseAnalyzerElement(element, parserContext, properties); + parseReducerElement(element, parserContext, factoryBeanProperties); + parseCollectorElement(element, parserContext, factoryBeanProperties, + properties); - Element analyzerElement = DomUtils.getChildElementByTagName(element, ANALYZER_ELEMENT); + String partitionHandlerBeanName = name + ".partitionHandler"; + registry.registerBeanDefinition(partitionHandlerBeanName, partitionHandlerDefinition); + factoryBeanProperties.add("partitionHandler", new RuntimeBeanReference(partitionHandlerBeanName)); - if(analyzerElement != null) { - String analyzerName = analyzerElement.getAttribute(REF); - properties.add(PARTITION_ANALYZER_PROPERTY, new RuntimeBeanReference(analyzerName)); - new PropertyParser(analyzerName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(analyzerElement); - } - - Element reducerElement = DomUtils.getChildElementByTagName(element, REDUCER_ELEMENT); - - if(reducerElement != null) { - String reducerName = reducerElement.getAttribute(REF); - factoryBeanProperties.add(PARTITION_REDUCER_PROPERTY, new RuntimeBeanReference(reducerName)); - new PropertyParser(reducerName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(reducerElement); - } + } + private void parseCollectorElement(Element element, + ParserContext parserContext, + MutablePropertyValues factoryBeanProperties, + MutablePropertyValues properties) { Element collectorElement = DomUtils.getChildElementByTagName(element, COLLECTOR_ELEMENT); if(collectorElement != null) { @@ -112,11 +103,40 @@ public class PartitionParser { factoryBeanProperties.add(LISTENERS_PROPERTY, new RuntimeBeanReference(collectorName)); new PropertyParser(collectorName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(collectorElement); } + } - String partitionHandlerBeanName = name + ".partitionHandler"; - registry.registerBeanDefinition(partitionHandlerBeanName, partitionHandlerDefinition); - factoryBeanProperties.add("partitionHandler", new RuntimeBeanReference(partitionHandlerBeanName)); + private void parseReducerElement(Element element, + ParserContext parserContext, + MutablePropertyValues factoryBeanProperties) { + Element reducerElement = DomUtils.getChildElementByTagName(element, REDUCER_ELEMENT); + if(reducerElement != null) { + String reducerName = reducerElement.getAttribute(REF); + factoryBeanProperties.add(PARTITION_REDUCER_PROPERTY, new RuntimeBeanReference(reducerName)); + new PropertyParser(reducerName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(reducerElement); + } + } + + private void parseAnalyzerElement(Element element, + ParserContext parserContext, MutablePropertyValues properties) { + Element analyzerElement = DomUtils.getChildElementByTagName(element, ANALYZER_ELEMENT); + + if(analyzerElement != null) { + String analyzerName = analyzerElement.getAttribute(REF); + properties.add(PARTITION_ANALYZER_PROPERTY, new RuntimeBeanReference(analyzerName)); + new PropertyParser(analyzerName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(analyzerElement); + } + } + + private void paserMapperElement(Element element, + ParserContext parserContext, MutablePropertyValues properties) { + Element mapperElement = DomUtils.getChildElementByTagName(element, MAPPER_ELEMENT); + + if(mapperElement != null) { + String mapperName = mapperElement.getAttribute(REF); + properties.add(PARTITION_MAPPER_PROPERTY, new RuntimeBeanReference(mapperName)); + new PropertyParser(mapperName, parserContext, BatchArtifactType.STEP_ARTIFACT, name).parseProperties(mapperElement); + } } private void registerCollectorAnalyzerQueue(ParserContext parserContext) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/partition/JsrPartitionHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/partition/JsrPartitionHandler.java index 634ba437b..780fc17c9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/partition/JsrPartitionHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/partition/JsrPartitionHandler.java @@ -25,7 +25,6 @@ import java.util.Properties; import java.util.Queue; import java.util.Set; import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.LinkedBlockingQueue; @@ -189,8 +188,7 @@ public class JsrPartitionHandler implements PartitionHandler, InitializingBean { private void processFinishedPartitions( final List