设为首页 加入收藏

TOP

spring加载bean流程解析(三)
2019-10-09 19:56:03 】 浏览:216
Tags:spring 加载 bean 流程 解析
.println("==>BeanPostProcessor.postProcessBeforeInitialization");
        }
        return null;
    }


    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (BEAN_NAME.equals(beanName)) {
            System.out.println("==>BeanPostProcessor.postProcessAfterInitialization");
        }
        return null;
    }



    @Override
    public void afterSingletonsInstantiated() {
        System.out.println("==>SmartInitializingSingleton.afterSingletonsInstantiated");


    }


    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
        if (BEAN_NAME.equals(beanName)) {
            System.out.println("==>InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation");
        }
        return null;
    }


    @Override
    public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
        if (BEAN_NAME.equals(beanName)) {
            System.out.println("==>InstantiationAwareBeanPostProcessor.postProcessAfterInstantiation");
        }
        return false;
    }


    @Override
    public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
        System.out.println("==>InstantiationAwareBeanPostProcessor.postProcessPropertyValues");
        return null;
    }


    @Override
    public void destroy() throws Exception {
        System.out.println("==>DisposableBean.destroy");
    }
}


 


5.3:启动容器:



六:总结


      本篇博客主要是介绍了Spring的一些实例化的过程,高屋建瓴的分析了一下spring的bean加载过程,没有详细展开某个细节分析。spring的内部源码非常复杂,每个接口的实现类都在5个以上,如果深入细节,恐怕不是一篇博客能讲清楚的。这篇博客的目的就是在阐述spring的基本脉络中心路线顺序,首先我们需要有一个总体的认识,然后再深入到细节就是轻而易举的了。这也是一种学习的方法论,通过本篇博客我希望能梳理清楚spring的基本流程,对spring有一个比较清晰的认识。并且学习到优秀开源框架的设计基本思想,还有就是进一步提升自己的阅读源码的能力。


首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇深入理解动态代理源码 下一篇通过编写扫雷游戏提高你的 Bash ..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目