zoukankan      html  css  js  c++  java
  • 【spring源码学习】spring的事务管理源码学习

    一、抽象概念

    1、事务管理器

    接口:org.springframework.transaction.PlatformTransactionManager

    实现类:org.springframework.jdbc.datasource.DataSourceTransactionManager

    2、事务定义和配置

    事务定义接口:org.springframework.transaction.TransactionDefinition

    事务配置接口:org.springframework.transaction.interceptor.TransactionAttribute

    接口实现类:org.springframework.transaction.interceptor.RuleBasedTransactionAttribute

    3、事务配置源

    接口:org.springframework.transaction.interceptor.TransactionAttributeSource

    接口实现类:org.springframework.transaction.annotation.AnnotationTransactionAttributeSource

    4、事务增强器

    实现:org.springframework.transaction.interceptor.TransactionInterceptor (Advice接口实现)

    5、事务切面管理

    切面:org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor(Advisor的接口实现)

    切点:org.springframework.transaction.interceptor.TransactionAttributeSourcePointcut(Pointcut的接口实现)

    类过滤器:org.springframework.aop.TrueClassFilter(ClassFilter接口实现)

    方法过滤器:org.springframework.transaction.interceptor.TransactionAttributeSourcePointcut(MethodMatcher的接口实现)

    增强:org.springframework.transaction.interceptor.TransactionInterceptor (Advice接口实现)

    二、事务传播机制

    事务传播行为类型

    说明

    PROPAGATION_REQUIRED

    如果当前没有事务,就新建一个事务,如果已经存在一个事务中,加入到这个事务中。这是最常见的选择。

    PROPAGATION_SUPPORTS

    支持当前事务,如果当前没有事务,就以非事务方式执行。

    PROPAGATION_MANDATORY

    使用当前的事务,如果当前没有事务,就抛出异常。

    PROPAGATION_REQUIRES_NEW

    新建事务,如果当前存在事务,把当前事务挂起。

    PROPAGATION_NOT_SUPPORTED

    以非事务方式执行操作,如果当前存在事务,就把当前事务挂起。

    PROPAGATION_NEVER

    以非事务方式执行,如果当前存在事务,则抛出异常。

    PROPAGATION_NESTED

    如果当前存在事务,则在嵌套事务内执行。如果当前没有事务,则执行与PROPAGATION_REQUIRED类似的操作。

    事务拦截器-创建事务(事务传播机制的流程图)

  • 相关阅读:
    js原生小小总结(二)
    js原生小小总结(一)
    js原生小小总结
    寻找峰值
    第一个错误的版本
    [JSOI2018] 战争
    CF232E Quick Tortoise
    [JLOI2015] 骗我呢
    CF1428G Lucky Numbers
    CF1239E Turtle
  • 原文地址:https://www.cnblogs.com/shangxiaofei/p/11923712.html
Copyright © 2011-2022 走看看