zoukankan      html  css  js  c++  java
  • @EnableTransactionalManager 发生了什么

    @EnableTransactionalManager

    1. 利用TransactionManagementConfigurationSelector 给容器中注入bean,导入2个组件:

      • AutoProxyRegistrar
      • ProxyTransactionManagementConfiguration
    2. AutoProxyRegistrar
      InfrastructureAdvisorAutoProxyCreator 给容器中注册一个这个组件

      类uml图中可以看出,这个组件和aop中的实现很类似

      file

      该组件利用后置处理器在对象创建之后,返回一个代理对象,代理对象执行方法利用拦截器链进行调用

    3. ProxyTransactionManagementConfiguration

      1. 给容器中添加事务增强器
        • 事务增强器要用到事务的注解信息,用AnnotationTransactionAttributeSource,解析事务的注解参数

        • 事务拦截器 TransactionInterceptor ,保存了事务属性,事务管理器,是一个 MethodInterceptor ,在目标方法执行的时候执行拦截器链。

          TransactionAttribute txAttr = tas != null ? tas.getTransactionAttribute(method, targetClass) : null;
          PlatformTransactionManager tm = this.determineTransactionManager(txAttr);
          
          1. 先获取事务的属性
          2. 获取PlatformTransactionManager,如果事先没有添加,则从ioc中获取PlatformTransactionManager,
          3. 执行目标方法,如果异常,获取到事务管理器,利用事务管理器回滚这次操作。如果正常,利用事务管理器,提交事务。

    https://github.com/fulln

  • 相关阅读:
    夜神模拟器连接电脑
    Appium+python 多设备自动化测试
    appium+python 连接手机设备的yaml配置文件
    appium+python自动化测试连接设备
    Ansible 学习目录
    Python 时间处理
    获取本机网卡ip地址
    Ansible playbook 使用
    ansible hosts配置
    python os和sys模块使用
  • 原文地址:https://www.cnblogs.com/wzqshb/p/11771499.html
Copyright © 2011-2022 走看看