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

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

  • 相关阅读:
    spring: web学习笔记1异常处理:No adapter for handler
    maven: maven编译时指定maven库,即指定profile
    spring: 一些基本配置也许只有自己能够读懂
    ruby: rdoc生成文档的好工具
    php: eclipse 编辑 php
    ssh免密码登录, 发送命令到多个Linux
    ruby: 使用netbeans debug ruby
    maven: maven创建工程,web工程等普通java app, web app
    IE, firefox竖向 横向滚动条处理
    获取指定进程在一段时间内cpu和内存的最大最小值【调试版】
  • 原文地址:https://www.cnblogs.com/shangxiaofei/p/11923712.html
Copyright © 2011-2022 走看看