How do I override a Spring bean definition yet still reference the overriden bean?
Posted
by Kevin
on Stack Overflow
See other posts from Stack Overflow
or by Kevin
Published on 2010-03-13T06:24:30Z
Indexed on
2010/03/13
6:35 UTC
Read the original article
Hit count: 237
I'm attempting to implement a delegate Service provider by overriding the bean definition for the original service with my delegate Service. However, as the name would imply, the delegate Service needs a reference to the original service to delegate calls to.
I'm having trouble figuring out how to override the bean definition while using the original bean def without running into a circular reference issue.
For example:
<!-- Original service def in spring-context.xml -->
<bean id="service" class="com.mycompany.Service"/>
<!-- Overridden definition in spring-plugin-context.xml -->
<bean id="service" class="com.mycompany.DelegatedService"/>
<constructor-arg ref="service"/>
</bean>
Is this possible?
© Stack Overflow or respective owner