I’d like to be able to load spring context.xml files on-the-fly, so that they are wired with previously loaded contexts (meaning, in contextA.xml I can ref a bean defined in contextB.xml which was already loaded). I would like for existing beans to not be destroyed and then created whenever a context is added.
Share
It’s easy enough to do, most of the BeanFactory and ApplicationContext implementations have the concept of a parent context.
see http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/beans/factory/xml/XmlBeanFactory.html
References inside the new context that can not be resolved within it’s self are passed up the parent to and to it’s parent.
Note you can get hold of the current application context by implementing
ApplicationContextAware.