<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

	<bean id="prototypeTest" class="org.springframework.tests.sample.beans.SideEffectBean" scope="prototype">
		<property name="count"><value>10</value></property>
	</bean>

	<bean id="threadLocalTs" class="org.springframework.aop.target.ThreadLocalTargetSource">
		<property name="targetBeanName"><value>prototypeTest</value></property>
	</bean>

	<bean id="debugInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor" />

	<!--
		We want to invoke the getStatsMixin method on our ThreadLocal invoker
	-->
	<bean id="statsAdvisor" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
		<property name="targetObject"><ref local="threadLocalTs" /></property>
		<property name="targetMethod"><value>getStatsMixin</value></property>
	</bean>

	<!--
		This will create a bean for each thread ("apartment")
	-->
	<bean id="apartment" class="org.springframework.aop.framework.ProxyFactoryBean">
		<property name="interceptorNames"><value>debugInterceptor,statsAdvisor</value></property>
		<property name="targetSource"><ref local="threadLocalTs"/></property>
		<!-- Necessary as have a mixin and want to avoid losing the class,
			 because there's no target interface -->
		<property name="proxyTargetClass"><value>true</value></property>
	</bean>

	<!-- ================ Definitions for second ThreadLocalTargetSource ====== -->

	<bean id="test" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
		<property name="name"><value>Rod</value></property>
		<property name="spouse"><ref local="wife"/></property>
	</bean>

	<bean id="wife" class="org.springframework.tests.sample.beans.TestBean">
		<property name="name"><value>Kerry</value></property>
	</bean>

	<bean id="threadLocalTs2" class="org.springframework.aop.target.ThreadLocalTargetSource">
		<property name="targetBeanName"><value>test</value></property>
	</bean>

	<bean id="threadLocal2" class="org.springframework.aop.framework.ProxyFactoryBean">
		<property name="targetSource"><ref local="threadLocalTs2"/></property>
	</bean>

</beans>
