com.atomikos.jdbc.AbstractDataSourceBean#getConnection()

public Connection getConnection() throws SQLException {if (LOGGER.isDebugEnabled()) {LOGGER.logDebug(this + ": getConnection()...");}Connection connection = null;this.init();try {//比较关键的一行代码,调用的com.atomikos.datasource.pool.ConnectionPoolWithSynchronizedValidation方法//该方法最终拿到的就是AtomikosConnectionProxyconnection = (Connection)this.connectionPool.borrowConnection();} catch (CreateConnectionException var3) {this.throwAtomikosSQLException("Failed to grow the connection pool", var3);} catch (PoolExhaustedException var4) {this.throwAtomikosSQLException("Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.");} catch (ConnectionPoolException var5) {this.throwAtomikosSQLException("Error borrowing connection", var5);}if (LOGGER.isTraceEnabled()) {LOGGER.logTrace(this + ": returning " + connection);}return connection;}

AtomikosConnectionProxy类分析

com.atomikos.jdbc.AtomikosConnectionProxy#invoke

public Object invoke(Object proxy, Method method, Object[] args) throws SQLException {String methodName = method.getName();if (methodName.equals("getInvocationHandler")) {return this;} else if (methodName.equals("reap")) {if (LOGGER.isDebugEnabled()) {LOGGER.logDebug(this + ": reaping pending connection...");}this.reap();if (LOGGER.isTraceEnabled()) {LOGGER.logTrace(this + ": reap done!");}return null;} else if (methodName.equals("isClosed")) {if (LOGGER.isDebugEnabled()) {LOGGER.logDebug(this + ": isClosed()...");}Object ret = this.closed;if (LOGGER.isTraceEnabled()) {LOGGER.logTrace(this + ": isClosed() returning " + ret);}return ret;} else if (this.closed && !this.methodAllowedAfterClose(method)) {String msg;if (this.reaped) {msg = "Connection has been reaped - calling " + methodName + " is no longer allowed! Increase reapTimeout to avoid this problem.";AtomikosSQLException.throwAtomikosSQLException(msg);} else {msg = "Connection was already closed - calling " + methodName + " is no longer allowed!";AtomikosSQLException.throwAtomikosSQLException(msg);}return null;} else {//在这里,获取连接时,第一步会走这里,这一步会去根据当前线程创建CompositeTransaction放到本地线程里面if (this.isEnlistedInGlobalTransaction()) {if (XA_INCOMPATIBLE_METHODS.contains(methodName)) {AtomikosSQLException.throwAtomikosSQLException("Cannot call method '" + methodName + "' while a global transaction is running");}if (methodName.equals("setAutoCommit") && args[0].equals(Boolean.TRUE)) {AtomikosSQLException.throwAtomikosSQLException("Cannot call 'setAutoCommit(true)' while a global transaction is running");}if (methodName.equals("getAutoCommit")) {return Boolean.FALSE;}}if (ENLISTMENT_METHODS.contains(methodName)) {try {this.enlist();} catch (Exception var8) {this.sessionHandleState.notifySessionErrorOccurred();JdbcConnectionProxyHelper.convertProxyError(var8, "Error enlisting in transaction - connection might be broken? Please check the logs for more information...");}}Object ret = null;if (CLOSE_METHODS.contains(methodName) && args == null) {this.close();return null;} else {try {if (LOGGER.isDebugEnabled()) {LOGGER.logDebug(this + ": calling " + this.formatCallDetails(method, args) + "...");}//com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl去创建一个连接返回ret = method.invoke(this.delegate, args);} catch (Exception var7) {this.sessionHandleState.notifySessionErrorOccurred();JdbcConnectionProxyHelper.convertProxyError(var7, "Error delegating '" + methodName + "' call");}if (LOGGER.isTraceEnabled()) {LOGGER.logTrace(this + ": " + methodName + " returning " + ret);}if (ret instanceof Statement) {Statement s = (Statement)ret;this.addStatement(s);}return ret;}}}

(三)以jdbc步骤来分析atomikos 源码-获取连接相关推荐

  1. Linux内核 eBPF基础:kprobe原理源码分析:源码分析

    Linux内核 eBPF基础 kprobe原理源码分析:源码分析 荣涛 2021年5月11日 在 <Linux内核 eBPF基础:kprobe原理源码分析:基本介绍与使用>中已经介绍了kp ...

  2. struts2 处理请求流程分析(结合源码)1- 孤星随缘ツ http://t.sina.com.cn/samzhxing-iteye技术网站...

    struts2 处理请求流程分析(结合源码)1- 孤星随缘ツ http://t.sina.com.cn/samzhxing-iteye技术网站 2011年08月01日 struts2 源码版本2.0. ...

  3. 【Android 热修复】热修复原理 ( 类加载分析 | 分析 PathClassLoader 源码 | 分析 BaseDexClassLoader 源码 | 分析 PathDexList 源码 )

    文章目录 一.分析 PathClassLoader 源码 二.分析 BaseDexClassLoader 源码 三.分析 PathDexList 源码 四. 源码资源 一.分析 PathClassLo ...

  4. 【Android 电量优化】JobScheduler 源码分析 ( JobServiceContext 源码分析 | 闭环操作总结 | 用户提交任务 | 广播接收者接受相关广播触发任务执行 )★

    文章目录 一.JobServiceContext 引入 二.JobServiceContext 源码分析 三.用户在应用层如何使用 JobScheduler 四.用户提交任务 五.广播接收者监听广播触 ...

  5. python爬取天气预报源代码_python抓取天气并分析 实例源码

    [实例简介] Python代码抓取获取天气预报信息源码讲解.这是一个用Python编写抓取天气预报的代码示例,用python写天气查询软件程序很简单.这段代码可以获取当地的天气和.任意城市的天气预报, ...

  6. C语言 阿拉伯数字转换为汉语大写数字金额程序分析及源码

    C语言 阿拉伯数字转换为汉语大写数字金额程序分析及源码 数据结构:用一个整型变量储存输入数字   大家可能会感觉用字符串取位更方便一些·· 但是相应的,字符串失去了数字原有的意思 00100和100对 ...

  7. Android 事件分发机制分析及源码详解

    Android 事件分发机制分析及源码详解 文章目录 Android 事件分发机制分析及源码详解 事件的定义 事件分发序列模型 分发序列 分发模型 事件分发对象及相关方法 源码分析 事件分发总结 一般 ...

  8. 如何快速阅读并分析Android源码

    很多时候为了解决一个问题必须先理解Android系统的运行原理,这时候就得阅读应用层框架的源码.学会阅读系统源码或者他人的代码,这是研发必备的技能之一,只有了解别人写的东西才能在他之上更好的行事,同时 ...

  9. k8s client-go源码分析 informer源码分析(3)-Reflector源码分析

    k8s client-go源码分析 informer源码分析(3)-Reflector源码分析 1.Reflector概述 Reflector从kube-apiserver中list&watc ...

最新文章

  1. mysql2008 limit,在SQL Server中实现 Limit m, n 的功能
  2. java点到直线的投影点到经纬度_12分高考答题必刷题型,“空间向量分析点到线的距离问题”...
  3. matlab散点拟合系数,matlab离散型数据拟合方程,求系数,哪个大神能说说方法
  4. Linux 字符设备驱动开发基础(四)—— ioctl() 函数解析
  5. HighCharts中几种tooltip的显示格式
  6. ERmaster 数据库设计 ,显示中文逻辑名
  7. 常见语法错误:sizeof和strlen strlen获取指针指向的数组长度
  8. script-百度换肤效果
  9. sonar扫的是class还是Java_如何在同一个项目中为java和javascript配置Sonarqube扫描程序...
  10. C++11强类型枚举——枚举类
  11. 转发 eclipse 取消javascript 验证
  12. 中国30家值得信赖的大数据采集公司汇总!
  13. Open mv识别图形形状及颜色
  14. Completed 404 NOT_FOUND,Whitelabel Error Page
  15. 产品经理的常见面试问题
  16. java内存泄漏怎么检测_JAVA内存泄漏原因和内存泄漏检测工具
  17. 计算机应用基础试题及答案试卷号7074,电路试卷及的答案.doc
  18. 信息检索导论-干货速览
  19. SSM茶叶销售管理系统
  20. 汇编语言学习笔记(终)

热门文章

  1. 每日签到html特效,jQuery实现日历每日签到网页特效
  2. 新纪元期货提示:选择正规期货 谨防非法黑平台 远离骗局
  3. 众至上网行为管理,管控内网行为,提升安全水平
  4. 简单的谷歌logo设计
  5. 计算机应用技术实训室建设发展,计算机应用技术系实验室、实训基地建设规划...
  6. 同是利润增长:英伟达与英特尔股价表现迥异背后
  7. 学小语种和计算机哪个更好,学习小语种专业哪家强?这几所语言类高校最合适...
  8. C#word转pdf出现的问题
  9. Ubuntu 20.04 蓝牙适配器使用
  10. 苹果公司CEO乔布斯的一次演讲