Make StepScope a BeanFactoryPostProcessor.

BATCH-88: StatisticsProvider is a leaky abstraction
http://opensource.atlassian.com/projects/spring/browse/BATCH-88
This commit is contained in:
dsyer
2007-08-24 10:59:19 +00:00
parent a68146df4d
commit e35a35f4bc
4 changed files with 93 additions and 49 deletions

View File

@@ -66,6 +66,16 @@ public class StepContextAwareStepScopeTests extends TestCase {
assertEquals(context, bean.context);
}
// public void testScopedBeanWithInner() throws Exception {
// StepSynchronizationManager.open();
// ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("scope-tests.xml", getClass());
// TestBean bean = ((TestBean) applicationContext.getBean("inner")).child;
// assertNotNull(bean);
// assertEquals("bar", bean.name);
// StepSynchronizationManager.close();
// assertEquals(1, list.size());
// }
public static class TestBean {
String name;
TestBean child;

View File

@@ -1,35 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
<property name="scopes">
<map>
<!-- ideally we want the scope to be an inner bean - it's fine if it isn't a BeanFactoryPostProcessor -->
<entry key="step" value-ref="scope"/>
</map>
</property>
</bean>
<bean id="scope" class="org.springframework.batch.execution.scope.StepScope" />
<bean id="bean" class="org.springframework.batch.execution.scope.StepContextAwareStepScopeTests$TestBean" scope="step" destroy-method="close">
<property name="name" value="foo"/>
</bean>
<bean id="inner" class="org.springframework.batch.execution.scope.StepContextAwareStepScopeTests$TestBean" scope="step">
<property name="child">
<bean class="org.springframework.batch.execution.scope.StepContextAwareStepScopeTests$TestBean" destroy-method="close"/>
</property>
</bean>
<bean id="aware" class="org.springframework.batch.execution.scope.StepContextAwareStepScopeTests$TestBeanAware" scope="step">
<property name="name" value="bar"/>
</bean>
</beans>
<bean class="org.springframework.batch.execution.scope.StepScope" />
<bean id="bean"
class="org.springframework.batch.execution.scope.StepContextAwareStepScopeTests$TestBean"
scope="step" destroy-method="close">
<property name="name" value="foo" />
</bean>
<bean id="inner"
class="org.springframework.batch.execution.scope.StepContextAwareStepScopeTests$TestBean"
scope="step">
<property name="child">
<bean
class="org.springframework.batch.execution.scope.StepContextAwareStepScopeTests$TestBean"
destroy-method="close" scope="step">
<property name="name" value="bar" />
</bean>
</property>
<property name="name" value="foo" />
</bean>
<bean id="aware"
class="org.springframework.batch.execution.scope.StepContextAwareStepScopeTests$TestBeanAware"
scope="step">
<property name="name" value="bar" />
</bean>
</beans>