事务管理器初始化流程

总体流程

1
2
3
4
5
6
7
8
9
10
创建 TransactionManagerImple
创建事务管理器对象
读取 narayana 的 xml 配置,进行属性赋值
获取 recovery 模块
加载恢复模块
事务恢复日志的初始化
初始化事务日志存储服务
JDBC方式存储
建表
文件方式存储

创建 TransactionManager 流程

Narayana 会通过 BeanPopulator 反射创建对应的 TransactionManager 实例,并读取用户自定义的 xml 属性反射赋值到 TransactionManager 实例里。

1
TransactionManager transactionManager = jtaPropertyManager.getJTAEnvironmentBean().getTransactionManager();

调用链路如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
jta.common.jtaPropertyManager#getJTAEnvironmentBean
加载配置文件,创建 JTAEnvironmentBean
com.arjuna.common.internal.util.propertyservice.BeanPopulator#getDefaultInstance
com.arjuna.common.internal.util.propertyservice.BeanPopulator#getNamedInstance
com.arjuna.common.util.propertyservice.PropertiesFactory#getDefaultProperties
获取用户自定义的配置属性
com.arjuna.common.util.propertyservice.PropertiesFactory#initPropertiesFactory
使用 stax 或 sax 解析 xml 配置
com.arjuna.common.util.propertyservice.PropertiesFactory#isStaxAvailable
com.arjuna.common.util.propertyservice.AbstractPropertiesFactory#getDefaultProperties
获取xml配置信息
com.arjuna.common.util.propertyservice.AbstractPropertiesFactory#initDefaultProperties
com.arjuna.common.util.ConfigurationInfo#getPropertiesFile
获取配置文件
com.arjuna.common.util.propertyservice.AbstractPropertiesFactory#getPropertiesFromFile
com.arjuna.common.util.propertyservice.FileLocator#locateFile
按照路径优先级,定位配置文件
1.根据 System.getProperty("com.arjuna.ats.arjuna.common.propertiesFile")路径指定配置文件
com.arjuna.common.util.propertyservice.FileLocator#locateByProperty
按照 user.dir, user.home, java.home 顺序查找配置文件,返回文件路径
com.arjuna.common.util.propertyservice.FileLocator#locateByResource
根据 classLoader 加载配置文件
com.arjuna.common.util.propertyservice.AbstractPropertiesFactory#loadFromFile
读取 xml 配置文件
com.arjuna.common.util.propertyservice.PropertiesFactoryStax#loadFromXML
com.arjuna.common.util.propertyservice.PropertiesFactoryStax$1#resolveEntity
com.arjuna.common.util.propertyservice.StringPropertyReplacer#replaceProperties
com.arjuna.common.util.propertyservice.StringPropertyReplacer#replaceProperties
com.arjuna.common.util.propertyservice.AbstractPropertiesFactory#applySystemProperties
应用系统配置属性
com.arjuna.common.internal.util.propertyservice.BeanPopulator#configureFromProperties
反射给 Narayana 配置对象里的属性赋值
com.arjuna.common.internal.util.propertyservice.BeanPopulator#capitalizeFirstLetter
com.arjuna.common.internal.util.propertyservice.BeanPopulator#handleSimpleProperty
com.arjuna.common.internal.util.propertyservice.BeanPopulator#getValueFromProperties
com.arjuna.common.internal.util.propertyservice.BeanPopulator#handleGroupProperty
com.arjuna.common.internal.util.propertyservice.BeanPopulator#getValueFromProperties
jta.common.JTAEnvironmentBean#setXaRecoveryNodes
jta.common.JTAEnvironmentBean#getTransactionManager
创建 TransactionManagerImple,调用无参构造方法
com.arjuna.common.internal.util.ClassloadingUtility#loadAndInstantiateClass
反射加载并实例化
com.arjuna.common.internal.util.ClassloadingUtility#loadClass
com.arjuna.common.internal.util.ClassloadingUtility#loadClass
jta.common.jtaPropertyManager#getJTAEnvironmentBean
com.arjuna.common.internal.util.propertyservice.BeanPopulator#getDefaultInstance