KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > proxool > ProxyConnectionIF


1 /*
2  * This software is released under a licence similar to the Apache Software Licence.
3  * See org.logicalcobwebs.proxool.package.html for details.
4  * The latest version is available at http://proxool.sourceforge.net
5  */

6 package org.logicalcobwebs.proxool;
7
8 import java.sql.Connection JavaDoc;
9 import java.sql.SQLException JavaDoc;
10 import java.sql.Statement JavaDoc;
11
12 /**
13  * Contains most of the functionality that we require to manipilate the
14  * connection. The subclass of this defines how we delegate to the
15  * real connection.
16
17  * @version $Revision: 1.7 $, $Date: 2005/10/07 08:18:24 $
18  * @author bill
19  * @author $Author: billhorsman $ (current maintainer)
20  * @since Proxool 0.7
21  */

22 public interface ProxyConnectionIF extends ConnectionInfoIF {
23
24     /**
25      * Changes the status and lets the ConnectionPool know so that it
26      * can keep count of how many connections are at each status.
27      * This method obtains a write lock.
28      * @param oldStatus the expected existing status. if the existing
29      * status is not this value then no change is made and false is returned.
30      * @param newStatus the status to change to
31      * @return true if status changed successfully, or false if no change made
32      * (because of unexpected existing status).
33      */

34     boolean setStatus(int oldStatus, int newStatus);
35
36     /**
37      * Forces the new status regardless of the old state
38      * @param newStatus the status to change to
39      * @return true if status changed successfully, or false if no change made (should
40      * always return true)
41      * @see #setStatus(int, int)
42      */

43     boolean setStatus(int newStatus);
44
45     /**
46      * Mark this connection for expiry (destruction) as soon as it stops
47      * being active.
48      * @param reason why we are marking this connection
49      * @see #isMarkedForExpiry
50      */

51     void markForExpiry(String JavaDoc reason);
52
53     /**
54      * Whether this connection is due for expiry
55      * @return true if it is due for expiry
56      * @see #markForExpiry
57      */

58     boolean isMarkedForExpiry();
59
60     /**
61      * Why this connection is marked (for instance, if a thread has
62      * marked it for expiry then it's nice to know why)
63      * @return reasonForMark
64      */

65     String JavaDoc getReasonForMark();
66
67     /**
68      * The real, delegate connection that we are using
69      * @return connection
70      */

71     Connection JavaDoc getConnection();
72
73     /**
74      * @return true if the status is null
75      */

76     boolean isNull();
77
78     /**
79      * @return true if the status is available
80      */

81     boolean isAvailable();
82
83     /**
84      * @return true if the status is active
85      */

86     boolean isActive();
87
88     /**
89      * @return true if the status is offline
90      */

91     boolean isOffline();
92
93     /**
94      * Really close the connection, as opposed to just putting it back
95      * in the pool.
96      */

97     void reallyClose() throws SQLException JavaDoc;
98
99     /**
100      * @see ConnectionInfoIF#getRequester
101      */

102     void setRequester(String JavaDoc requester);
103
104     /**
105      * Doesn't really close the connection, just puts it back in the pool. And tries to
106      * reset all the methods that need resetting.
107      * @see Connection#close
108      */

109     void close() throws SQLException JavaDoc;
110
111     /**
112      * Notify that a statement has been closed and won't need closing
113      * when the connection is returned to the poo.
114      * @param statement the statement that has just been closed
115      */

116     void registerClosedStatement(Statement JavaDoc statement);
117
118     /**
119      * Find out if the delegated connection is close. Just calling isClosed() on the
120      * proxied connection will only indicate whether it is in the pool or not.
121      * @return true if the connection is really closed, or if the connection is null
122      * @throws java.sql.SQLException if anything went wrong
123      */

124     boolean isReallyClosed() throws SQLException JavaDoc;
125
126     ConnectionPoolDefinitionIF getDefinition();
127
128     /**
129      * Get the most recent of all the {@link #getSqlCalls()}
130      * @return the SQL (could be a batch of SQLs)
131      */

132     String JavaDoc getLastSqlCall();
133
134 }
135
136
137 /*
138  Revision history:
139  $Log: ProxyConnectionIF.java,v $
140  Revision 1.7 2005/10/07 08:18:24 billhorsman
141  New sqlCalls gives list of SQL calls rather than just he most recent (for when a connection makes more than one call before being returned to the pool)
142
143  Revision 1.6 2005/09/26 10:01:31 billhorsman
144  Added lastSqlCall when trace is on.
145
146  Revision 1.5 2005/05/04 16:24:13 billhorsman
147  include a reference to the definition so we can spot it changing.
148
149  Revision 1.4 2003/03/10 15:26:49 billhorsman
150  refactoringn of concurrency stuff (and some import
151  optimisation)
152
153  Revision 1.3 2003/03/03 11:11:58 billhorsman
154  fixed licence
155
156  Revision 1.2 2003/02/26 16:05:53 billhorsman
157  widespread changes caused by refactoring the way we
158  update and redefine pool definitions.
159
160  Revision 1.1 2003/01/27 18:26:39 billhorsman
161  refactoring of ProxyConnection and ProxyStatement to
162  make it easier to write JDK 1.2 patch
163
164  */
Popular Tags