From 8143e667681cd1e4f35139a30d260a8e50fe638c Mon Sep 17 00:00:00 2001 From: dsyer Date: Mon, 7 Sep 2009 16:58:39 +0000 Subject: [PATCH] RESOLVED - issue BATCH-1397: Late binding only happens once per ApplicationContext if expression is in substring http://jira.springframework.org/browse/BATCH-1397 --- .../core/scope/util/PlaceholderTargetSource.java | 2 +- ...ltipleContextPlaceholderTargetSourceTests.java | 15 +++++++++++++++ ...ontextPlaceholderTargetSourceTests-context.xml | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderTargetSource.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderTargetSource.java index 592434f39..04e6ac19d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderTargetSource.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderTargetSource.java @@ -330,7 +330,7 @@ public class PlaceholderTargetSource extends SimpleBeanTargetSource implements I // Otherwise it might contain embedded keys so we try to // replace those String visitedString = resolveStringValue(stringValue); - typedStringValue.setValue(visitedString); + value = new TypedStringValue(visitedString); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java index 82b6c17cb..dc9f669b5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java @@ -53,6 +53,10 @@ public class MultipleContextPlaceholderTargetSourceTests { @Qualifier("simple") private TestBean simple; + @Autowired + @Qualifier("nested") + private TestBean nested; + @Autowired @Qualifier("list") private TestBean list; @@ -88,6 +92,17 @@ public class MultipleContextPlaceholderTargetSourceTests { } + @Test + public void testMultipleNestedValueFromProperties() throws Exception { + + for (int i = 0; i < 4; i++) { + final String value = "bar" + i; + attributes = Collections.singletonMap("foo", value); + assertEquals("foo-bar" + i, nested.getName()); + } + + } + @Test public void testMultipleValueInList() throws Exception { diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests-context.xml index 30e331586..672f3c01d 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests-context.xml @@ -16,6 +16,16 @@ + + + + + + + + + + + + +