Spring事物源码篇解读
【文章来自:on the way】

初始调用路线图:

?org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator

        postProcessAfterInitialization->wrapIfNecessary->getAdvicesAndAdvisorsForBean

初始看法:

类初始化完成后调用AbstractAutoProxyCreator的Bean后处理器,扫描没有做过代理的类,对需要增强的类创建代理。

类和增强是分离的,在这实现自动匹配。

涉及到的类

1:org.springframework.aop.support.AopUtil

2:org.springframework.aop.aspectj.annotation.AspectJProxyFactory

3:org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator->{wrapIfNecessary,postProcessAfterInitialization}

4:org.springframework.test.context.junit4.SpringJUnit4ClassRunner

5:org.springframework.test.context.TestContextManager

6:org.springframework.test.context.DefaultTestContext(加载ApplicationContext)(getApplicationContext)

7:org.springframework.test.context.CacheAwareContextLoaderDelegate

8:org.springframework.transaction.annotation.SpringTransactionAnnotationParser(在这找到的突破口)

9:org.springframework.test.context.support.AbstractGenericContextLoader

10:org.springframework.aop.support.AopUtils 切面工具类(关键)

11:org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator->findAdvisorsThatCanApply

12:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory->doCreateBean

查看Spring 加载过程中加载的类

org.springframework.beans.factory.support.BeanDefinitionReaderUtils->registerBeanDefinition

AnnotationConfigUtils->registerAnnotationConfigProcessors(注解配置工具类)

事务注解:

AopAutoProxyConfigurer

configureAutoProxyCreator

AopConfigUtils->registerAutoProxyCreatorIfNecessary

事务代理类注入时机

AopConfigUtils->registerOrEscalateApcAsRequired

AopNamespaceUtils->registerAutoProxyCreatorIfNecessary

基于事务注解的bean,使用annotation定义事务

加载过程中解析过程

org.springframework.beans.factory.xml.BeanDefinitionParserDelegate->parseCustomElement

NamespaceHandlerSupport->parse->findParserForElement

org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser->parse

AopAutoProxyConfigurer->configureAutoProxyCreator

AopNamespaceUtils->registerAutoProxyCreatorIfNecessary

AopConfigUtils->registerAutoProxyCreatorIfNecessary->registerOrEscalateApcAsRequired

registry->registerBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME, beanDefinition)

AUTO_PROXY_CREATOR_BEAN_NAME : org.springframework.aop.config.internalAutoProxyCreator

beanDefinition : org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator

bean 扩展接口的实现原理

AbstractAutowireCapableBeanFactory->applyBeanPostProcessorsAfterInitialization

启动步骤:

DefaultTestContext->getApplicationContext(cacheAwareContextLoaderDelegate.loadContext(mergedContextConfiguration))

->loadContextInternal(mergedContextConfiguration)->(SmartContextLoader smartContextLoader = (SmartContextLoader) contextLoader;?applicationContext = smartContextLoader.loadContext(mergedContextConfiguration);)

->org.springframework.test.context.support.AbstractGenericContextLoader->loadContext

热门文章

月是儿时圆
【文章来自:遇见】

俗话说家有一老如有一宝,这句话最能体现……


月圆中秋
【文章来自:Malcolm】

一字雁阵,拉开了金秋的帷幕;云卷云舒……


故乡,中秋了
【文章来自:Irene】

又是一年中秋的月圆,又是一缕团圆的时光……


细说中秋那些传说
【文章来自:雨】

相传,远古时候天上有十日同时出现,晒得……


中秋节的由来
【文章来自:快乐】

中秋有悠久的历史,和其它传统节日一样……


春江花月夜
【文章来自:Sophie】

春江潮水连海平,海上明月共潮生。滟滟随……


走进宋词赏明月
【文章来自:耳朵】

老黄历八月十五晚上,关了手机,抬头望望……


深入理解 C 语言的函数调用过程
【文章来自:项籍】

本文主要从进程栈空间的层面复习一下C语……


嵌入式系统中,Python与C/C++哪方更为适用?
【文章来自:无忧天使】

长久以来,C/C++一直编译着嵌入式系统编……


Spring事物源码篇解读
【文章来自:on the way】

org.springframework.aop.framework……


金笛M1206B用于网络交换机和服务器的监控和预警
【文章来自:金笛后花园】

随着计算机数量的不断地增大和功能的不断……


金笛短信猫应用消防调度指挥系统
【文章来自:金笛后花园】

华脉公司依托互联在线推出采用先进技术……


金笛短信应用于智能交通领域
【文章来自:金笛短信论坛】

北京某科技有限公司是一家集计算机软件……