001: /*
002: * @(#) ConnectionLeakEventImpl.java 1.0 02/08/01
003: */
004:
005: package org.smartlib.pool.core;
006:
007: import java.sql.*;
008:
009: /**
010: * This class provides an implementation of the ConnectionLeakEvent interface
011: * thus encapsulating a connection leak event.
012: *
013: * @author Sachin Shekar Shetty
014: * @version 1.0, 02/08/01
015: */
016:
017: public class ConnectionLeakEventImpl implements ConnectionLeakEvent {
018:
019: private Connection conn;
020: private String owner;
021: private long lastAccessedTime;
022: private long connectionObtainedTime;
023: private String poolName;
024:
025: /**
026: * @param conn Connection for which the time out has occured.
027: * @param owner Owner of the connection.
028: * @param lastAccessedTime Timestamp when the connection was last accessed
029: * directly or through Statements, PreparedStatements,
030: * CallableStatements.
031: * @param connectionObtainedTime Timestamp when the connection was obtained
032: * from the pool.
033: * @param poolName Name of the pool to which the connection belongs.
034: */
035: ConnectionLeakEventImpl(Connection conn, String owner,
036: long lastAccessedTime, long connectionObtainedTime,
037: String poolName) {
038:
039: this .conn = conn;
040: this .owner = owner;
041: this .lastAccessedTime = lastAccessedTime;
042: this .connectionObtainedTime = connectionObtainedTime;
043: this .poolName = poolName;
044:
045: }
046:
047: /**
048: * @return Connection which has been blocked by the consumer for more
049: * than the specified time.
050: */
051: public Connection getConnection() {
052:
053: return conn;
054:
055: }
056:
057: /**
058: * @return Owner of the connection.
059: */
060: public String getOwner() {
061:
062: return owner;
063:
064: }
065:
066: /**
067: * @return Timestamp when the connection was last accessed.
068: */
069: public long getLastAccessedTime() {
070:
071: return lastAccessedTime;
072:
073: }
074:
075: /**
076: * @return Timestamp when connection was drawn from the pool.
077: */
078: public long getConnectionObtainedTime() {
079:
080: return connectionObtainedTime;
081:
082: }
083:
084: /**
085: * @return Name of the pool.
086: */
087: public String getPoolName() {
088:
089: return poolName;
090:
091: }
092:
093: // toString method , makes debugging easy.
094: public String toString() {
095:
096: StringBuffer sb = new StringBuffer();
097: sb.append("\nConnectionLeakEvent--------->");
098: sb.append("\n\tConnection: " + conn);
099: sb.append("\n\tOwner: " + owner);
100: sb.append("\n\tlastAccessedTime: " + lastAccessedTime);
101: sb.append("\n\tconnectionObtainedTime : "
102: + connectionObtainedTime);
103: sb.append("\n\tpoolName : " + poolName);
104: return (sb.toString());
105:
106: }
107:
108: }
|