Spring 事务源码剖析
2022-01-14 13:10:38 0 举报
Spring 事务源码剖析
作者其他创作
大纲/内容
implements
调用事务拦截器
txInfo.getTransactionManager().commit(txInfo.getTransactionStatus())
事务提交
ArithmeticException
获取TransactionStatus
利用ThreadLocal缓存旧的事务信息
AbstractAdvisorAutoProxyCreator
事务回滚条件,为true 则rollback,否则commit
IndexOutOfBoundsException
事务异常处理
extends
try{}catch(Throwable ex){}finally {}
MethodInterceptor
SQLException
RuntimeException
retVal = invocation.proceedWithInvocation()
DefaultTransactionAttribute#rollbackOn
事务管理的配置类
AspectJ对事务管理支持的配置类
@Bean
ImportBeanDefinitionRegistrar
事务传播行为
回滚规则调用
@Import
异常逻辑处理
txInfo.getTransactionManager().rollback(txInfo.getTransactionStatus())
Java异常体系
isExistingTransaction(transaction)
txInfo.transactionAttribute != null && txInfo.transactionAttribute.rollbackOn(ex)
从DataSourceTransactionManager中获取事务对象
ex instanceof RuntimeException || ex instanceof Error;
DelegatingTransactionAttribute#rollbackOn
装配bean
注册后置处理器
service.addAccount(\"fox\
tm.getTransaction(txAttr)
TransactionAspectSupport#invokeWithinTransaction
AdviceMode
DynamicAdvisedInterceptor#intercept
ProxyTransactionManagementConfiguration
非检查异常
利用后置处理器返回代理对象
事务回滚
Exception
commitTransactionAfterReturning(txInfo)
TransactionManagementConfigurationSelector
jdkDyamic
@EnableTransactionManagement
AnnotationTransactionAttributeSource
Throwable
执行业务逻辑,调用业务方法
AWTError
Object transaction = doGetTransaction()
OutOfMemoryError
AnnotationTransactionAspect
检查异常:非运行时异常(编译异常)
PROXY
true
TransactionInterceptor#invoke
程序入口
false
VirtualMachineError
cleanupTransactionInfo(txInfo)
ASPECTJ
NullPointerException
RuntimeException&Error会回滚
ImportSelector
TransactionInterceptor
false,当前不存在事务
创建事务
BeanFactoryTransactionAttributeSourceAdvisor
Error
AutoProxyRegistrar
如果没有配置rollbackRules,则调用默认规则
InfrastructureAdvisorAutoProxyCreator
CglibAopProxy.DynamicAdvisedInterceptor#intercept
IOException
StackOverflowError
cglib
AspectJTransactionManagementConfiguration
RuleBasedTransactionAttribute#rollbackOn
AspectJJtaTransactionManagementConfiguration
ReflectiveMethodInvocation#proceed
0 条评论
下一页