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类似的操作。

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

  • 相关阅读:
    CComboBox(组合框)控件 学习要点
    弹出菜单的实现
    剪贴板(clipboard)功能
    bash1---基本0
    CHAPTER 2 -----Reapresenting and Manipulating Information(1)
    关于Linux磁盘分区与双系统
    CHAPTER 1 ----- a tour of computer sysytems(3)
    CHAPTER 1 ----- a tour of computer sysytems(2)
    CHAPTER 1 ----- a tour of computer sysytems(1)
    [2017.4.14] 随笔一 ------头文件中用宏定义调试语句(引用C语言写爬虫的初学项目)
  • 原文地址:https://www.cnblogs.com/shangxiaofei/p/11923712.html
Copyright © 2011-2022 走看看