org.logicalcobwebs.proxool
类 ProxyConnection

java.lang.Object
  继承者 org.logicalcobwebs.proxool.ProxyConnection
所有已实现的接口:
Comparable, ConnectionInfoIF, ProxyConnectionIF

public class ProxyConnection
extends Object
implements ProxyConnectionIF

Manages a connection. This is wrapped up inside a...

从以下版本开始:
Proxool 0.10
版本:
$Revision: 1.40 $, $Date: 2007/05/15 23:17:21 $
作者:
bill, $Author: billhorsman $ (current maintainer)

字段摘要
 
从接口 org.logicalcobwebs.proxool.ConnectionInfoIF 继承的字段
MARK_FOR_EXPIRY, MARK_FOR_USE, STATUS_ACTIVE, STATUS_AVAILABLE, STATUS_NULL, STATUS_OFFLINE
 
构造方法摘要
protected ProxyConnection(Connection connection, long id, String delegateUrl, org.logicalcobwebs.proxool.ConnectionPool connectionPool, ConnectionPoolDefinitionIF definition, int status)
           
 
方法摘要
protected  void addOpenStatement(Statement statement)
          By calling this we can keep track of any statements that are left open when this connection is returned to the pool.
 void addSqlCall(String sqlCall)
           
 void close()
          Doesn't really close the connection, just puts it back in the pool.
 int compareTo(Object o)
          Compares using getId()
 boolean equals(Object obj)
          Whether the underlying connections are equal
 long getAge()
          The age in millseconds since this connection was built
 Date getBirthDate()
          Like ConnectionInfoIF.getBirthTime() but in Date format
 long getBirthTime()
          The time that this connection was created.
 Connection getConnection()
          The real, delegate connection that we are using
protected  org.logicalcobwebs.proxool.ConnectionPool getConnectionPool()
          The ConnectionPool that this connection belongs to
 ConnectionPoolDefinitionIF getDefinition()
          Get the definition that was used to create this connection
 String getDelegateHashcode()
          The hashcode (in hex) of the delegate connection object.
 String getDelegateUrl()
          The URL that this connection is using (the definition might have changed since this connection was built).
 long getId()
          A unique ID for this connection
 String getLastSqlCall()
          Get the most recent of all the ConnectionInfoIF.getSqlCalls()
 int getMark()
          Sometimes we want do something to a connection but can't because it is still active and we don't want to disrupt its use.
 String getProxyHashcode()
          The hashcode (in hex) of the ProxyConnection object.
 int getReasonCode()
          Get the reason why this connection is marked
 String getReasonForMark()
          Why this connection is marked (for instance, if a thread has marked it for expiry then it's nice to know why)
 String getRequester()
          The name of the thread that asked for this connection.
 String[] getSqlCalls()
          A log of the last SQL used on this connection.
 int getStatus()
          The status of the connection.
 long getTimeLastStartActive()
          When this connection was last given out.
 long getTimeLastStopActive()
          When this connection was last given back (or zero if it is still active).
 boolean isActive()
           
 boolean isAvailable()
           
 boolean isClosed()
          Whether this connection is available.
 boolean isMarkedForExpiry()
          Whether this connection is due for expiry
 boolean isNull()
           
 boolean isOffline()
           
 boolean isReallyClosed()
          Find out if the delegated connection is close.
 void markForExpiry(String reason)
          Mark this connection for expiry (destruction) as soon as it stops being active.
protected  void open()
          This gets called /just/ before a connection is served.
 void reallyClose()
          Close the connection for real
 void registerClosedStatement(Statement statement)
          Notify that a statement has been closed and won't need closing when the connection is returned to the poo.
 void setBirthTime(long birthTime)
           
 void setId(long id)
           
protected  void setNeedToReset(boolean needToReset)
          The subclass should call this to indicate that a change has been made to the connection that might mean it needs to be reset (like setting autoCommit to false or something).
 void setRequester(String requester)
           
 boolean setStatus(int newStatus)
          Forces the new status regardless of the old state
 boolean setStatus(int oldStatus, int newStatus)
          Changes the status and lets the ConnectionPool know so that it can keep count of how many connections are at each status.
 void setTimeLastStartActive(long timeLastStartActive)
           
 void setTimeLastStopActive(long timeLastStopActive)
           
 String toString()
           
 
从类 java.lang.Object 继承的方法
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

ProxyConnection

protected ProxyConnection(Connection connection,
                          long id,
                          String delegateUrl,
                          org.logicalcobwebs.proxool.ConnectionPool connectionPool,
                          ConnectionPoolDefinitionIF definition,
                          int status)
                   throws SQLException
参数:
connection - the real connection that is used
id - unique ID
delegateUrl -
connectionPool - the pool it is a member of
definition - the definition that was used to build it (could possibly be different from the one held in the connectionPool)
status - ConnectionInfoIF.STATUS_ACTIVE, ConnectionInfoIF.STATUS_AVAILABLE, STATUS_FORCE, ConnectionInfoIF.STATUS_NULL, or ConnectionInfoIF.STATUS_OFFLINE
抛出:
SQLException
方法详细信息

equals

public boolean equals(Object obj)
Whether the underlying connections are equal

覆盖:
Object 中的 equals
参数:
obj - the object (probably another connection) that we are being compared to
返回:
whether they are the same

isClosed

public boolean isClosed()
Whether this connection is available. (When you close the connection it doesn't really close, it just becomes available for others to use).

返回:
true if the connection is not active

setNeedToReset

protected void setNeedToReset(boolean needToReset)
The subclass should call this to indicate that a change has been made to the connection that might mean it needs to be reset (like setting autoCommit to false or something). We don't reset unless this has been called to avoid the overhead of unnecessary resetting.

参数:
needToReset - true if the connection might need resetting.

getConnectionPool

protected org.logicalcobwebs.proxool.ConnectionPool getConnectionPool()
The ConnectionPool that this connection belongs to

返回:
connectionPool

getDefinition

public ConnectionPoolDefinitionIF getDefinition()
Get the definition that was used to create this connection

指定者:
接口 ProxyConnectionIF 中的 getDefinition
返回:
definition

addOpenStatement

protected void addOpenStatement(Statement statement)
By calling this we can keep track of any statements that are left open when this connection is returned to the pool.

参数:
statement - the statement that we have just opened/created.
另请参见:
registerClosedStatement(java.sql.Statement)

registerClosedStatement

public void registerClosedStatement(Statement statement)
从接口 ProxyConnectionIF 复制的描述
Notify that a statement has been closed and won't need closing when the connection is returned to the poo.

指定者:
接口 ProxyConnectionIF 中的 registerClosedStatement
参数:
statement - the statement that has just been closed
另请参见:
ProxyConnectionIF.registerClosedStatement(java.sql.Statement)

reallyClose

public void reallyClose()
                 throws SQLException
Close the connection for real

指定者:
接口 ProxyConnectionIF 中的 reallyClose
抛出:
SQLException - if anything goes wrong

isReallyClosed

public boolean isReallyClosed()
                       throws SQLException
从接口 ProxyConnectionIF 复制的描述
Find out if the delegated connection is close. Just calling isClosed() on the proxied connection will only indicate whether it is in the pool or not.

指定者:
接口 ProxyConnectionIF 中的 isReallyClosed
返回:
true if the connection is really closed, or if the connection is null
抛出:
SQLException - if anything went wrong
另请参见:
ProxyConnectionIF.isReallyClosed()

close

public void close()
           throws SQLException
从接口 ProxyConnectionIF 复制的描述
Doesn't really close the connection, just puts it back in the pool. And tries to reset all the methods that need resetting.

指定者:
接口 ProxyConnectionIF 中的 close
抛出:
SQLException
另请参见:
ProxyConnectionIF.close()

open

protected void open()
This gets called /just/ before a connection is served. You can use it to reset some of the attributes. The lifecycle is: open() then close()


getMark

public int getMark()
从接口 ConnectionInfoIF 复制的描述
Sometimes we want do something to a connection but can't because it is still active and we don't want to disrupt its use. So we mark it instead and when it stops being active we can perform the necessary operation. The only thing we do at the moment is expire the connection (if it is too old for instance). And this will happen if the housekeeper decides it should but the connection is still active.

指定者:
接口 ConnectionInfoIF 中的 getMark

getStatus

public int getStatus()
从接口 ConnectionInfoIF 复制的描述
The status of the connection. Can be either: null, available, active or offline.

指定者:
接口 ConnectionInfoIF 中的 getStatus

setStatus

public boolean setStatus(int newStatus)
从接口 ProxyConnectionIF 复制的描述
Forces the new status regardless of the old state

指定者:
接口 ProxyConnectionIF 中的 setStatus
参数:
newStatus - the status to change to
返回:
true if status changed successfully, or false if no change made (should always return true)
另请参见:
ProxyConnectionIF.setStatus(int)

setStatus

public boolean setStatus(int oldStatus,
                         int newStatus)
从接口 ProxyConnectionIF 复制的描述
Changes the status and lets the ConnectionPool know so that it can keep count of how many connections are at each status. This method obtains a write lock.

指定者:
接口 ProxyConnectionIF 中的 setStatus
参数:
oldStatus - the expected existing status. if the existing status is not this value then no change is made and false is returned.
newStatus - the status to change to
返回:
true if status changed successfully, or false if no change made (because of unexpected existing status).
另请参见:
ProxyConnectionIF.setStatus(int, int)

getId

public long getId()
从接口 ConnectionInfoIF 复制的描述
A unique ID for this connection

指定者:
接口 ConnectionInfoIF 中的 getId

setId

public void setId(long id)

getBirthTime

public long getBirthTime()
从接口 ConnectionInfoIF 复制的描述
The time that this connection was created. The number of milliseconds since midnight, January 1, 1970 UTC.

指定者:
接口 ConnectionInfoIF 中的 getBirthTime
另请参见:
ConnectionInfoIF.getBirthTime()

getBirthDate

public Date getBirthDate()
从接口 ConnectionInfoIF 复制的描述
Like ConnectionInfoIF.getBirthTime() but in Date format

指定者:
接口 ConnectionInfoIF 中的 getBirthDate
返回:
birthDate
另请参见:
ConnectionInfoIF.getBirthDate()

getAge

public long getAge()
从接口 ConnectionInfoIF 复制的描述
The age in millseconds since this connection was built

指定者:
接口 ConnectionInfoIF 中的 getAge
另请参见:
ConnectionInfoIF.getAge()

setBirthTime

public void setBirthTime(long birthTime)
另请参见:
ConnectionInfoIF.getBirthTime()

getTimeLastStartActive

public long getTimeLastStartActive()
从接口 ConnectionInfoIF 复制的描述
When this connection was last given out. The number of milliseconds since midnight, January 1, 1970 UTC.

指定者:
接口 ConnectionInfoIF 中的 getTimeLastStartActive
另请参见:
ConnectionInfoIF.getTimeLastStartActive()

setTimeLastStartActive

public void setTimeLastStartActive(long timeLastStartActive)
另请参见:
ConnectionInfoIF.getTimeLastStartActive()

getTimeLastStopActive

public long getTimeLastStopActive()
从接口 ConnectionInfoIF 复制的描述
When this connection was last given back (or zero if it is still active). The number of milliseconds since midnight, January 1, 1970 UTC.

指定者:
接口 ConnectionInfoIF 中的 getTimeLastStopActive
另请参见:
ConnectionInfoIF.getTimeLastStopActive()

setTimeLastStopActive

public void setTimeLastStopActive(long timeLastStopActive)
另请参见:
ConnectionInfoIF.getTimeLastStopActive()

getRequester

public String getRequester()
从接口 ConnectionInfoIF 复制的描述
The name of the thread that asked for this connection.

指定者:
接口 ConnectionInfoIF 中的 getRequester
另请参见:
ConnectionInfoIF.getRequester()

setRequester

public void setRequester(String requester)
指定者:
接口 ProxyConnectionIF 中的 setRequester
另请参见:
ConnectionInfoIF.getRequester()

isNull

public boolean isNull()
指定者:
接口 ProxyConnectionIF 中的 isNull
返回:
true if the status is null
另请参见:
ProxyConnectionIF.isNull()

isAvailable

public boolean isAvailable()
指定者:
接口 ProxyConnectionIF 中的 isAvailable
返回:
true if the status is available
另请参见:
ProxyConnectionIF.isAvailable()

isActive

public boolean isActive()
指定者:
接口 ProxyConnectionIF 中的 isActive
返回:
true if the status is active
另请参见:
ProxyConnectionIF.isActive()

isOffline

public boolean isOffline()
指定者:
接口 ProxyConnectionIF 中的 isOffline
返回:
true if the status is offline
另请参见:
ProxyConnectionIF.isOffline()

markForExpiry

public void markForExpiry(String reason)
从接口 ProxyConnectionIF 复制的描述
Mark this connection for expiry (destruction) as soon as it stops being active.

指定者:
接口 ProxyConnectionIF 中的 markForExpiry
参数:
reason - why we are marking this connection
另请参见:
ProxyConnectionIF.markForExpiry(java.lang.String)

isMarkedForExpiry

public boolean isMarkedForExpiry()
从接口 ProxyConnectionIF 复制的描述
Whether this connection is due for expiry

指定者:
接口 ProxyConnectionIF 中的 isMarkedForExpiry
返回:
true if it is due for expiry
另请参见:
ProxyConnectionIF.isMarkedForExpiry()

getReasonForMark

public String getReasonForMark()
从接口 ProxyConnectionIF 复制的描述
Why this connection is marked (for instance, if a thread has marked it for expiry then it's nice to know why)

指定者:
接口 ProxyConnectionIF 中的 getReasonForMark
返回:
reasonForMark
另请参见:
ProxyConnectionIF.getReasonForMark()

getConnection

public Connection getConnection()
从接口 ProxyConnectionIF 复制的描述
The real, delegate connection that we are using

指定者:
接口 ProxyConnectionIF 中的 getConnection
返回:
connection
另请参见:
ProxyConnectionIF.getConnection()

toString

public String toString()
覆盖:
Object 中的 toString
另请参见:
Object.toString()

getDelegateUrl

public String getDelegateUrl()
从接口 ConnectionInfoIF 复制的描述
The URL that this connection is using (the definition might have changed since this connection was built).

指定者:
接口 ConnectionInfoIF 中的 getDelegateUrl
返回:
delegateUrl
另请参见:
ConnectionInfoIF.getDelegateUrl()

getProxyHashcode

public String getProxyHashcode()
从接口 ConnectionInfoIF 复制的描述
The hashcode (in hex) of the ProxyConnection object. This uniquely identifies this proxy connection.

指定者:
接口 ConnectionInfoIF 中的 getProxyHashcode
返回:
proxyHashcode
另请参见:
ConnectionInfoIF.getProxyHashcode()

getDelegateHashcode

public String getDelegateHashcode()
从接口 ConnectionInfoIF 复制的描述
The hashcode (in hex) of the delegate connection object. This uniquely identifies the underlying connection.

指定者:
接口 ConnectionInfoIF 中的 getDelegateHashcode
返回:
delegateHashcode
另请参见:
ConnectionInfoIF.getDelegateHashcode()

compareTo

public int compareTo(Object o)
Compares using getId()

指定者:
接口 Comparable 中的 compareTo
参数:
o - must be another ConnectionInfoIF implementation
返回:
the comparison
另请参见:
Comparable.compareTo(Object)

getSqlCalls

public String[] getSqlCalls()
从接口 ConnectionInfoIF 复制的描述
A log of the last SQL used on this connection. Only populated if ConnectionPoolDefinitionIF.isTrace() is enabled.

指定者:
接口 ConnectionInfoIF 中的 getSqlCalls
返回:
the most recent SQL to be used

getLastSqlCall

public String getLastSqlCall()
从接口 ProxyConnectionIF 复制的描述
Get the most recent of all the ConnectionInfoIF.getSqlCalls()

指定者:
接口 ProxyConnectionIF 中的 getLastSqlCall
返回:
the SQL (could be a batch of SQLs)

getReasonCode

public int getReasonCode()
从接口 ProxyConnectionIF 复制的描述
Get the reason why this connection is marked

指定者:
接口 ProxyConnectionIF 中的 getReasonCode
返回:
ConnectionListenerIF.MAXIMUM_ACTIVE_TIME_EXPIRED, ConnectionListenerIF.HOUSE_KEEPER_TEST_FAIL, ConnectionListenerIF.FATAL_SQL_EXCEPTION_DETECTED, ConnectionListenerIF.MANUAL_EXPIRY, ConnectionListenerIF.MAXIMUM_CONNECTION_LIFETIME_EXCEEDED, ConnectionListenerIF.RESET_FAIL, ConnectionListenerIF.SHUTDOWN, or ConnectionListenerIF.VALIDATION_FAIL

addSqlCall

public void addSqlCall(String sqlCall)


Copyright © 2014. All rights reserved.