1

Say I have a Swing/Spring standalone application. I am wondering whether Spring does detect runtime changes to its configuration file such as this one (assuming the file is on the classpath):

Commenting second bean and adding first bean as below:

<beans>
    <bean id="randonNumberGenerator"  class="com.me.MyGenerator"/>

    <!--
    <bean id="randonNumberGenerator"  class="com.someoneelse.ADifferentGenerator"/>
    -->
</beans>

Will Spring change the implementation at runtime as expected?

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
Julien
  • 11
  • 2
  • possible duplicate of [Automatic configuration reinitialization in Spring](http://stackoverflow.com/questions/461710/automatic-configuration-reinitialization-in-spring) – MarcoS May 23 '11 at 11:42

2 Answers2

0

I think you can use the "AbstractRefreshableApplicationContext" to refresh the context.

AbstractRefreshableApplicationContext refreshableContext = new ClassPathXmlApplicationContext (  "applicationContextRefreshable.xml" );
 refreshableContext.refresh ( );

For details you can have a look here

Asraful Haque
  • 753
  • 8
  • 11
  • Whilst this may theoretically answer the question, we would like you to include the essential parts of the linked article in your answer, and provide the [link for reference](http://meta.stackexchange.com/q/8259). Failing to do that leaves the answer at risk from link rot. Feel free to edit more useful information into this answer and flag to undelete. – Kev May 07 '12 at 13:33
0

I don't think Spring provides a way to reload the configuration on-the-fly. It could be possible by re-instantiating the entire ApplicationContext, but that would mean that all beans are recreated etc., and internal state of the software would probably fly out the window in the process.

esaj
  • 15,875
  • 5
  • 38
  • 52