diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/StepContextFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/StepContextFactoryBean.java index 0417821a2..b3e459ef7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/StepContextFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/StepContextFactoryBean.java @@ -40,7 +40,7 @@ public class StepContextFactoryBean implements FactoryBean { @Override public StepContext getObject() throws Exception { org.springframework.batch.core.StepExecution stepExecution = StepSynchronizationManager.getContext().getStepExecution(); - Properties properties = batchPropertyContext.getBatchProperties(stepExecution.getStepName()); + Properties properties = batchPropertyContext.getStepLevelProperties(stepExecution.getStepName()); return new StepContext(stepExecution, properties); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/BatchPropertyContext.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/BatchPropertyContext.java index 6c4746f74..0bd41e09c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/BatchPropertyContext.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/BatchPropertyContext.java @@ -61,6 +61,24 @@ public class BatchPropertyContext { } } + public Properties getStepLevelProperties(String beanName) { + Properties properties = new Properties(); + + if (batchProperties.containsKey(beanName)) { + properties.putAll(batchProperties.get(beanName)); + } else { + if(beanName.startsWith("scopedTarget")) { + beanName = beanName.substring(13); + } + + if(batchProperties.containsKey(beanName)) { + properties.putAll(batchProperties.get(beanName)); + } + } + + return properties; + } + /** *

* Obtains the batch {@link Properties} for the provided bean name / batch artifact. The returned diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JobPropertyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JobPropertyTests.java index cd358b226..049c432ee 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JobPropertyTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JobPropertyTests.java @@ -491,8 +491,8 @@ public class JobPropertyTests { org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName2")); org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName1").equals("step2PropertyValue1")); org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName2").equals("step2PropertyValue2")); - org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName1").equals("jobPropertyValue1")); - org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName2").equals("jobPropertyValue2")); + org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName1") == null); + org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName2") == null); return null; }