zoukankan      html  css  js  c++  java
  • Spring类加载初始化Bean链路

    1.spring类加载

    AbstractApplicationContext.finishBeanFactoryInitialization(...);
        beanFactory.preInstantiateSingletons();
           DefaultListableBeanFactory.getBean(beanName);
              AbstractBeanFactory.doGetBean();
                AbstractAutowireCapableBeanFactory.createBean(....)
                    populateBean(beanName, mbd, instanceWrapper);
                    initializeBean(...)
                     //调用BeanPostProcessor.postProcessBeforeInitialization()方法
                      applyBeanPostProcessorsBeforeInitialization(wrappedBean, beanName);
                     //调用BeanPostProcessor.postProcessBeforeInitialization()方法
                      applyBeanPostProcessorsAfterInitialization(wrappedBean, beanName);
    

    2.BeanPostProcessor有个实现类CommonAnnotationBeanPostProcessor,专门处理@PostConstruct @PreDestroy注解。

    CommonAnnotationBeanPostProcessor的父类InitDestroyAnnotationBeanPostProcessor()
     InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization()
        InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata()
            // 组装生命周期元数据
            InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata()
                // 查找@PostConstruct注释的方法
                InitDestroyAnnotationBeanPostProcessor.initAnnotationType
                // 查找@PreDestroy注释方法
                InitDestroyAnnotationBeanPostProcessor.destroyAnnotationType
     // 反射调用          
     metadata.invokeInitMethods(bean, beanName);    
    
  • 相关阅读:
    Rotation Kinematics
    离职 mark
    PnP 问题方程怎么列?
    DSO windowed optimization 代码 (4)
    Adjoint of SE(3)
    IMU 预积分推导
    DSO windowed optimization 代码 (3)
    DSO windowed optimization 代码 (2)
    OKVIS 代码框架
    DSO windowed optimization 代码 (1)
  • 原文地址:https://www.cnblogs.com/ae6623/p/15176841.html
Copyright © 2011-2022 走看看