Hi,
I tried google'ing for this but to no avail , please forgive me if this has been answered before.
Let's assume a very basic configuration:
During my application's runtime I want to replace the singleton bean "aFactory" with a different bean (that is of course 'compatible' to 'aFactory', a subclass for example) that gets instantiated and populated by my application (because the bean's creation depends on data only available during runtime). All other singletons that have a reference to 'aFactory' should automatically be re-wired to use the new bean instance.Code:<beans ...> <bean id="aFactory" class="aClass">.....</bean> <bean id="bean1" class="..."> <property name="factory"><ref bean="aFactory"/></property> </bean> <bean id="bean2" class="..."> <property name="factory"><ref bean="aFactory"/></property> </bean> </beans>
This _should_ be possible because the part of my (single-threaded) application that would trigger this replacement 'owns' the ApplicationContext and it is therefore safe to re-wire (or even discard and recreate) the whole object graph / context.
Basically, what I'm looking for is something like a
BeanFactory#replaceAndRewireSingleton(String beanId, Object newBean)
method.
Any suggestions ?
Thanks in advance,
Tobias


Reply With Quote