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

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

  • 相关阅读:
    【LeetCode】205. Isomorphic Strings
    Syscall param open(filename) points to unaddressable byte(s)
    五种主要多核并行编程方法分析与比较
    计算机时间复杂度和空间复杂度
    CUDA学习笔记(二)【转】
    CUDA学习笔记(一)【转】
    CUDA Thread Indexing
    Intel MKL函数,如何得到相同的计算结果?【转】
    CUDA编程
    GPU(CUDA)学习日记(十一)------ 深入理解CUDA线程层次以及关于设置线程数的思考
  • 原文地址:https://www.cnblogs.com/shangxiaofei/p/11923712.html
Copyright © 2011-2022 走看看