001: /*
002: * This software is released under a licence similar to the Apache Software Licence.
003: * See org.logicalcobwebs.proxool.package.html for details.
004: * The latest version is available at http://proxool.sourceforge.net
005: */
006: package org.logicalcobwebs.proxool;
007:
008: import java.sql.Connection;
009: import java.sql.SQLException;
010: import java.sql.Statement;
011:
012: /**
013: * Contains most of the functionality that we require to manipilate the
014: * connection. The subclass of this defines how we delegate to the
015: * real connection.
016:
017: * @version $Revision: 1.7 $, $Date: 2005/10/07 08:18:24 $
018: * @author bill
019: * @author $Author: billhorsman $ (current maintainer)
020: * @since Proxool 0.7
021: */
022: public interface ProxyConnectionIF extends ConnectionInfoIF {
023:
024: /**
025: * Changes the status and lets the ConnectionPool know so that it
026: * can keep count of how many connections are at each status.
027: * This method obtains a write lock.
028: * @param oldStatus the expected existing status. if the existing
029: * status is not this value then no change is made and false is returned.
030: * @param newStatus the status to change to
031: * @return true if status changed successfully, or false if no change made
032: * (because of unexpected existing status).
033: */
034: boolean setStatus(int oldStatus, int newStatus);
035:
036: /**
037: * Forces the new status regardless of the old state
038: * @param newStatus the status to change to
039: * @return true if status changed successfully, or false if no change made (should
040: * always return true)
041: * @see #setStatus(int, int)
042: */
043: boolean setStatus(int newStatus);
044:
045: /**
046: * Mark this connection for expiry (destruction) as soon as it stops
047: * being active.
048: * @param reason why we are marking this connection
049: * @see #isMarkedForExpiry
050: */
051: void markForExpiry(String reason);
052:
053: /**
054: * Whether this connection is due for expiry
055: * @return true if it is due for expiry
056: * @see #markForExpiry
057: */
058: boolean isMarkedForExpiry();
059:
060: /**
061: * Why this connection is marked (for instance, if a thread has
062: * marked it for expiry then it's nice to know why)
063: * @return reasonForMark
064: */
065: String getReasonForMark();
066:
067: /**
068: * The real, delegate connection that we are using
069: * @return connection
070: */
071: Connection getConnection();
072:
073: /**
074: * @return true if the status is null
075: */
076: boolean isNull();
077:
078: /**
079: * @return true if the status is available
080: */
081: boolean isAvailable();
082:
083: /**
084: * @return true if the status is active
085: */
086: boolean isActive();
087:
088: /**
089: * @return true if the status is offline
090: */
091: boolean isOffline();
092:
093: /**
094: * Really close the connection, as opposed to just putting it back
095: * in the pool.
096: */
097: void reallyClose() throws SQLException;
098:
099: /**
100: * @see ConnectionInfoIF#getRequester
101: */
102: void setRequester(String 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;
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 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;
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 getLastSqlCall();
133:
134: }
135:
136: /*
137: Revision history:
138: $Log: ProxyConnectionIF.java,v $
139: Revision 1.7 2005/10/07 08:18:24 billhorsman
140: 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)
141:
142: Revision 1.6 2005/09/26 10:01:31 billhorsman
143: Added lastSqlCall when trace is on.
144:
145: Revision 1.5 2005/05/04 16:24:13 billhorsman
146: include a reference to the definition so we can spot it changing.
147:
148: Revision 1.4 2003/03/10 15:26:49 billhorsman
149: refactoringn of concurrency stuff (and some import
150: optimisation)
151:
152: Revision 1.3 2003/03/03 11:11:58 billhorsman
153: fixed licence
154:
155: Revision 1.2 2003/02/26 16:05:53 billhorsman
156: widespread changes caused by refactoring the way we
157: update and redefine pool definitions.
158:
159: Revision 1.1 2003/01/27 18:26:39 billhorsman
160: refactoring of ProxyConnection and ProxyStatement to
161: make it easier to write JDK 1.2 patch
162:
163: */
|