RESOLVED - issue BATCH-1397: Late binding only happens once per ApplicationContext if expression is in substring

http://jira.springframework.org/browse/BATCH-1397
This commit is contained in:
dsyer
2009-09-07 16:58:39 +00:00
parent db485dbd10
commit 8143e66768
3 changed files with 31 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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 {

View File

@@ -16,6 +16,16 @@
</property>
</bean>
<bean id="nested" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="targetSource">
<bean
class="org.springframework.batch.core.scope.util.PlaceholderTargetSource">
<property name="contextFactory" ref="context" />
<property name="targetBeanName" value="nestedTarget" />
</bean>
</property>
</bean>
<bean id="list" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="targetSource">
<bean
@@ -41,6 +51,11 @@
<property name="name" value="%{attributes[foo]}" />
</bean>
<bean id="nestedTarget"
class="org.springframework.batch.core.scope.util.MultipleContextPlaceholderTargetSourceTests$TestBean">
<property name="name" value="foo-%{attributes[foo]}" />
</bean>
<bean id="listTarget"
class="org.springframework.batch.core.scope.util.MultipleContextPlaceholderTargetSourceTests$TestBean">
<property name="names">