随笔分类 -  Spring CORE 源码解读

摘要:AbstractApplicationContext.refresh()1、加载节点,获取节点的命名空间 如果命名空间为beans,默认处理import , alias , bean , beans 如果不是benas命名空间,则读取spring jar包中的META-INF/spring.hander,然后根据命名空间找到对应的解析器 加载beanDefinition2、prepareBeanFactory3、postProcessBeanFactory(beanFactory);4、invokeBeanFactoryPostProcessors(beanFactory); 执行容器中实现. 阅读全文
posted @ 2013-11-06 09:53 benx621 阅读(1568) 评论(0) 推荐(0)
摘要:会注入如下classConfigurationClassPostProcessor1、遍历所有bean,如果class有注解Configuration或Component或class的方法有Bean2、利用ConfigurationClassParser 解析 class,把bean 加载到 容器中AutowiredAnnotationBeanPostProcessor1、把autowired注解的method或field注入到bean中RequiredAnnotationBeanPostProcessor1、检查如果 有Required注解,但是没有注入依赖,那么将抛错CommonAnnot 阅读全文
posted @ 2013-11-06 09:51 benx621 阅读(149) 评论(0) 推荐(0)
摘要:常用接口ApplicationContextAware void setApplicationContext(ApplicationContext applicationContext)BeanNameAware void setBeanName(String name)InitializingBean void afterPropertiesSet()DisposableBean void destroy()BeanDefinitionRegistryPostProcessor void postProcessBeanDefinitionRegistry(BeanDefinitionRegi 阅读全文
posted @ 2013-11-06 09:48 benx621 阅读(476) 评论(0) 推荐(0)
摘要:会注入如下classSet beanDefinitions = ClassPathBeanDefinitionScanner.doScan(package);加载目录下面有Component、Controller.class、Repository.class、Service.class注解的class这个包含了功能 阅读全文
posted @ 2013-11-06 09:47 benx621 阅读(275) 评论(0) 推荐(0)