KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > smartlib > pool > core > ConnectionLeakEventImpl


1 /*
2  * @(#) ConnectionLeakEventImpl.java 1.0 02/08/01
3  */

4
5 package org.smartlib.pool.core;
6
7 import java.sql.*;
8
9 /**
10  * This class provides an implementation of the ConnectionLeakEvent interface
11  * thus encapsulating a connection leak event.
12  *
13  * @author Sachin Shekar Shetty
14  * @version 1.0, 02/08/01
15  */

16
17 public class ConnectionLeakEventImpl implements ConnectionLeakEvent {
18
19     private Connection conn;
20     private String JavaDoc owner;
21     private long lastAccessedTime;
22     private long connectionObtainedTime;
23     private String JavaDoc poolName;
24
25     /**
26      * @param conn Connection for which the time out has occured.
27      * @param owner Owner of the connection.
28      * @param lastAccessedTime Timestamp when the connection was last accessed
29      * directly or through Statements, PreparedStatements,
30      * CallableStatements.
31      * @param connectionObtainedTime Timestamp when the connection was obtained
32      * from the pool.
33      * @param poolName Name of the pool to which the connection belongs.
34      */

35     ConnectionLeakEventImpl(Connection conn, String JavaDoc owner,
36                     long lastAccessedTime, long connectionObtainedTime,
37                     String JavaDoc poolName) {
38         
39         this.conn = conn;
40         this.owner= owner;
41         this.lastAccessedTime = lastAccessedTime;
42         this.connectionObtainedTime = connectionObtainedTime;
43         this.poolName = poolName;
44     
45     }
46
47     /**
48      * @return Connection which has been blocked by the consumer for more
49      * than the specified time.
50      */

51     public Connection getConnection() {
52         
53         return conn;
54         
55     }
56
57     /**
58      * @return Owner of the connection.
59      */

60     public String JavaDoc getOwner() {
61
62         return owner;
63
64     }
65
66     /**
67      * @return Timestamp when the connection was last accessed.
68      */

69     public long getLastAccessedTime() {
70
71         return lastAccessedTime;
72
73     }
74
75     /**
76      * @return Timestamp when connection was drawn from the pool.
77      */

78     public long getConnectionObtainedTime() {
79
80         return connectionObtainedTime;
81         
82     }
83
84     /**
85      * @return Name of the pool.
86      */

87     public String JavaDoc getPoolName() {
88
89         return poolName;
90         
91     }
92     // toString method , makes debugging easy.
93
public String JavaDoc toString() {
94
95         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
96         sb.append("\nConnectionLeakEvent--------->");
97         sb.append("\n\tConnection: " + conn);
98         sb.append("\n\tOwner: " + owner);
99         sb.append("\n\tlastAccessedTime: " + lastAccessedTime );
100         sb.append("\n\tconnectionObtainedTime : " + connectionObtainedTime );
101         sb.append("\n\tpoolName : " + poolName );
102         return (sb.toString());
103
104     }
105     
106 }
107
Popular Tags