4.执行 Bean 的初始化方法和 BeanPostProcessor 的前置和后置处理方法
1.判断bean是否属于Aware接口的实现
1.如果bean属于BeanFactoryAware的实现则将当前的beanFactory引用set进bean的对应属性中
2.如果bean属于BeanClasLoaderAware的实现则将当前的beanClassLoader的引用set进bean的对应属性中<br>
3.如果bean属于BeanNameAware的实现,则将当前的beanName,set进bean的对应属性中
2. 执行 BeanPostProcessor Before 处理
1.获取BeanPostProcessor注册表
2.遍历执行postProcessBeforeInitialization前置方法
3.执行 Bean 对象的初始化方法(两种)
1.如果bean对象实现了InitializingBean接口则直接调用afterPropertiesSet方法
2.如果bean对象没有实现InitializingBean接口当时Beandefinition中有InitMethodName这个属性则通过反射来调用这个属性中的方法名
4. 执行 BeanPostProcessor After 处理
1.获取BeanPostProcessor注册表
2.遍历执行postProcessAfterInitialization后置方法
5.注册实现了 DisposableBean 接口的 Bean 对象(两种方式判断是否实现了DisposableBean接口,1.beandefinition中含有DestroyMethodName属性;2.bean实现了DisposableBean接口)
非 Singleton 类型的 Bean 不执行销毁方法
5.将bean对象实例加到单例bean容器中
1.如果beandefinition中singleton属性为true则加到单例bean容器中
2.如果是false则不加入到单例bean容器中