Narayana 事务 begin 流程
Narayana 事务 begin 流程整体流程12345检查事务状态获取超时时间创建事务对象 事务对象设置到 ThreadLocal 中,和当前线程绑定 插入事务测超时时间监控 使用 API123TransactionManager transactionManager = jtaPropertyManager.getJTAEnvironmentBean().getTransactionManager();// 开启全局事务transactionManager.begin(); 调用链路123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869internal.jta.transaction.arjunacore.BaseTransaction#begin开启事务 ...
Narayana启动-注册恢复模块流程
Narayana启动-注册恢复模块流程使用代码12// narayana 在启动阶段使用如下 api 加载恢复模块XARecoveryModulexaRecoveryModule = XARecoveryModule.getRegisteredXARecoveryModule(); 总体流程1234567891011121314151617注册恢复模块 反射创建 RecoveryEnvironmentBean 配置信息实例 加载 RecoveryActivators 启动 RecoveryActivators 初始化 PeriodicRecovery 设置恢复状态 INACTIVE 设置恢复mode ENABLED 加载恢复模块,module包括: 1.com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule ...
Narayana 事务管理器初始化流程
事务管理器初始化流程总体流程12345678910创建 TransactionManagerImple 创建事务管理器对象读取 narayana 的 xml 配置,进行属性赋值获取 recovery 模块 加载恢复模块事务恢复日志的初始化初始化事务日志存储服务 JDBC方式存储 建表 文件方式存储 创建 TransactionManager 流程Narayana 会通过 BeanPopulator 反射创建对应的 TransactionManager 实例,并读取用户自定义的 xml 属性反射赋值到 TransactionManager 实例里。 1TransactionManager transactionManager =...
springboot对接tomcat
springboot对接tomcat调用的地方在 ServletWebServerApplicationContext 里. 创建 webServergetWebServer:166, TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat)createWebServer:181, ServletWebServerApplicationContext (org.springframework.boot.web.servlet.context)onRefresh:154, ServletWebServerApplicationContext (org.springframework.boot.web.servlet.context)refresh:543, AbstractApplicationContext (org.springframework.context.support)refresh:142, ServletWebServerApplicationContext...
springboot conditional 注解
@Conditional满足指定条件的时候才将某个 bean 加载到应用上下文中. 比如 FreemarkerAutoConfiguration 这个自动化配置类的定义如下: 1234567@ConditionalOnClass(ThreadPoolTaskScheduler.class)@Configuration@EnableConfigurationProperties(TaskSchedulingProperties.class)@AutoConfigureAfter(TaskExecutionAutoConfiguration.class)public class TaskSchedulingAutoConfiguration { // ...} 这个自动化配置类被 @ConditionalOnClass 条件注解修饰, 这个条件注解存在的意义在于判断类加载器中是否存在 ThreadPoolTaskScheduler 这个类, 如果存在的话会在 Spring 容器中加载这个 TaskSchedulingAutoConfiguration...
spring-boot EnableAutoConfiguration
spring-boot EnableAutoConfiguration1234567891011121314151617181920212223242526272829- refresh() -> invokeBeanFactoryPostProcessors()- ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry() - ConfigurationClassPostProcessor.processConfigBeanDefinitions() - 1.parser.parse(candidates)比如此时candidates是SpringApplication启动类 - ConfigurationClassParser.parse() - 1.不同类型的 beanDefinition,调用不同的 parse(),parse()方法 -> processConfigurationClass() -...
Spring ConfigurationClassParser
Spring ConfigurationClassParser123456789101112131415161718192021- ConfigurationClassPostProcessor.processConfigBeanDefinitions()- 1.获取 registry 中的 beanDefinitionNames- 2.遍历beanDefinitionNames判断beanDefinition 是否是 @Configuration 配置类,若是则添加到 configCandidates 集合中- 3.configCandidates根据Order排序- 4.创建ConfigurationClassParser,配置类解析器- 5.遍历configCandidates,调用parser.parse()进行配置类解析 - ConfigurationClassParser.parse() - 1.遍历configCandidates,获取当前的beanDefinition -...
Spring component-scan实现
componet-scan分为 xml 配置 和 注解配置两种方式,二者入口不同,实现上没太多差别.都是先解析配置,根据配置的 basePackages 用asm扫描.class上是否有@Component注解,若有则生成beanName,注册到容器里即可. context:component-scan/实现配置1<context:component-scan base-package="com.zc"/> 切入点对于自定义标签的解析入口在 DefaultBeanDefinitionDocumentReader.parseCustomElement(ele); 里.1.先根据标签获取parser,这里是 ComponentScanBeanDefinitionParser 调用12345678910111213141516171819202122- NamespaceHandlerSupport.parse(): 根据元素获取parser进行处理,这里使用的是ComponentScanBeanDefinitionParser -...
spring-boot启动流程
spring-boot 启动 spingboot-start SpringApplication构造方法 使用 SpringFactoriesLoader 在 classpath 中查找并加载所有可用的 ApplicationContextInitializer 使用 SpringFactoriesLoader 在 classpath 中查找并加载所有可用的 ApplicationListener 通过stackTrace里的main方法查找启动类 SpringApplication.run() 创建StopWatch计时器 通过 SpringFactoriesLoader 查找并加载 SpringApplicationRunListener 列表,调用 SpringApplicationRunListener.started() 方法 创建Environment configureEnvironment() listeners.environmentPrepared(): 广播 ApplicationEnvironmentPreparedEvent...
idea搭建spring-boot环境
idea搭建spring-boot环境显示taggit tag 选择 v2.1.5.RELEASE 版本,这是我们项目里现在在用的版本,还比较新,最新的目前是 2.3.0. 拉自己的分支 建立我自己的分支,以后代码注释都写在这个分支上.v2.1.5.RELEASE-zc git checkout -b v2.1.5.RELEASE-zc v2.1.5.RELEASE v2.1.5.RELEASE 这个版本是可以选择 maven 或 gradle 构建的,我这里选的maven. 工程依赖的jar包很多,大概要下个半小时多. 将本地分支推到远程git push origin v2.1.5.RELEASE-zc 建立关联git push –set-upstream origin v2.1.5.RELEASE-zc 看看代码量spring-boot 总共代码45w行,纯代码 27w 行. idea attach sourceidea 的配置最终都落到 .idea 下的 xml 里,搜索 springboot 的 maven 配置文件,修改里面的...