Bean工厂

书中人 2019年09月17日 1,827次浏览
刷新bean工厂、生产内部bean工厂,DefaultListableBeanFactory
设置序列化ID

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);
		}
	}
  1. customizeBeanFactory子类可以覆盖、自定义bean工厂的配置
  2. loadBeanDefinitions加载bean的定义信息、此处以注解为例子、xml形式同理 TODO