/** * This implementation performs an actual refresh of this context's underlying bean factory, * shutting down the previous bean factory (if any) and initializing a fresh bean factory for the * next phase of the context's lifecycle. */ @Override protected final void refreshBeanFactory() throws BeansException { if (hasBeanFactory()) { destroyBeans(); closeBeanFactory(); } try { DefaultListableBeanFactory beanFactory = createBeanFactory(); beanFactory.setSerializationId(getId()); customizeBeanFactory(beanFactory); loadBeanDefinitions(beanFactory); synchronized (this.beanFactoryMonitor) { this.beanFactory = beanFactory; } } catch (IOException ex) { throw new ApplicationContextException( "I/O error parsing bean definition source for " + getDisplayName(), ex); } }
protected final void refreshBeanFactory() throws BeansException { // Shut down previous bean factory, if any. if (this.beanFactory != null) { this.beanFactory.destroySingletons(); this.beanFactory = null; } // Initialize fresh bean factory. try { DefaultListableBeanFactory beanFactory = createBeanFactory(); loadBeanDefinitions(beanFactory); this.beanFactory = beanFactory; if (logger.isInfoEnabled()) { logger.info( "Bean factory for application context [" + getDisplayName() + "]: " + beanFactory); } } catch (IOException ex) { throw new ApplicationContextException( "I/O error parsing XML document for application context [" + getDisplayName() + "]", ex); } }