connectionwrapper.java
来自「基于Jabber协议的即时消息服务器」· Java 代码 · 共 78 行
JAVA
78 行
/** * $RCSfile$ * $Revision: 37 $ * $Date: 2004-10-20 23:08:43 -0700 (Wed, 20 Oct 2004) $ * * Copyright (C) 2004 Jive Software. All rights reserved. * * This software is published under the terms of the GNU Public License (GPL), * a copy of which is included in this distribution. */package org.jivesoftware.database;import org.jivesoftware.database.AbstractConnection;import org.jivesoftware.database.ConnectionPool;import java.sql.Connection;import java.sql.SQLException;/** * An implementation of the Connection interface that wraps an underlying * Connection object. It releases the connection back to a connection pool * when Connection.close() is called. * * @author Jive Software */public class ConnectionWrapper extends AbstractConnection { public ConnectionPool pool; public boolean checkedout = false; public long createTime; public long lockTime; public long checkinTime; public Exception exception; public boolean hasLoggedException = false; public ConnectionWrapper(Connection connection, ConnectionPool pool) { super(connection); this.pool = pool; createTime = System.currentTimeMillis(); lockTime = createTime; checkinTime = lockTime; } public void setConnection(Connection connection) { super.connection = connection; } /** * Instead of closing the underlying connection, we simply release * it back into the pool. */ public void close() throws SQLException { synchronized (this) { checkedout = false; checkinTime = System.currentTimeMillis(); } pool.freeConnection(); // Release object references. Any further method calls on the connection will fail. // super.connection = null; } public String toString() { if (connection != null) { return connection.toString(); } else { return "Jive Software Connection Wrapper"; } } public synchronized boolean isCheckedOut() { return checkedout; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?