|
[
Permlink
| « Hide
]
Morten Andersen-Gott added a comment - 11/Mar/08 06:45 AM
Complete source code that results in the exception. Requires Spring and aspectj.
Replacing the bean definitions in the description with the defnitions below, using the ProxyBeanFactory gives me the desired functionality, but with excess xml configuration.
<bean id="serviceATarget" class="com.test.ServiceAImpl"> <property name="serviceB" ref="serviceB"/> </bean> <bean id="serviceBTarget" class="com.test.ServiceBImpl"> <property name="serviceA" ref="serviceA"/> </bean> <bean id="serviceA" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"><value>com.test.ServiceA</value></property> <property name="target"><ref local="serviceATarget"/></property> <property name="interceptorNames"> <list> <value>traceInterceptor</value> </list> </property> </bean> <bean id="serviceB" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"><value>com.test.ServiceB</value></property> <property name="target"><ref local="serviceBTarget"/></property> <property name="interceptorNames"> <list> <value>traceInterceptor</value> </list> </property> </bean> <bean id="traceInterceptor" class="com.test.TraceInterceptor"> </bean> This is actually a known limitation of auto-proxying, not really a bug. The ProxyFactoryBean model uses different semantics (with the target instance being available for early access a a dedicated bean, in contrast to auto-proxying) which is why you can make it work in your case.
That said, I agree that it would be nice to make this work. I have prototyped a getEarlyBeanReference mechanism for our AutoProxyCreator that allows to obtain a proxy reference early (i.e. before the target instance is fully configured). This works fine already; I'll do some further testing before committing it later this week. Juergen This is committed now for inclusion in 2.5.3. The mechanism is relatively straightforward, so should work for any such scenario - with the usual general drawbacks of circular references, of course.
This will be available in tonight's 2.5.3 snapshot (http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR) already. Feel free to give it a try... Juergen |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||