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.util.Date;
009:
010: /**
011: * Provides information about an individual connection. You can get a collection
012: * of these from {@link ProxoolFacade#getConnectionInfos ProxoolFacade}. You
013: * get back information about all the connections in a particular pool.
014: *
015: * <pre>
016: * String alias = "myPool";
017: * Iterator i = ProxoolFacade.getConnectionInfos(alias).iterator();
018: * while (i.hasNext()) {
019: * ConnectionInfoIF c = (ConnectionInfoIF)i.next();
020: * ...
021: * }
022: * </pre>
023: *
024: * @version $Revision: 1.12 $, $Date: 2005/10/07 08:18:23 $
025: * @author billhorsman
026: * @author $Author: billhorsman $ (current maintainer)
027: */
028: public interface ConnectionInfoIF extends Comparable {
029:
030: /**
031: * Default - treat as normal
032: * @see #getMark
033: */
034: static final int MARK_FOR_USE = 0;
035:
036: /**
037: * The next time this connection is made available we should expire it.
038: * @see #getMark
039: */
040: static final int MARK_FOR_EXPIRY = 1;
041:
042: /**
043: * This is the start and end state of every connection
044: * @see #getStatus
045: */
046: static final int STATUS_NULL = 0;
047:
048: /**
049: * The connection is available for use
050: * @see #getStatus
051: */
052: static final int STATUS_AVAILABLE = 1;
053:
054: /**
055: * The connection is in use
056: * @see #getStatus
057: */
058: static final int STATUS_ACTIVE = 2;
059:
060: /**
061: * The connection is in use by the house keeping thread
062: * @see #getStatus
063: */
064: static final int STATUS_OFFLINE = 3;
065:
066: /**
067: * The time that this connection was created.
068: * The number of milliseconds
069: * since midnight, January 1, 1970 UTC.
070: */
071: long getBirthTime();
072:
073: /**
074: * Like {@link #getBirthTime} but in Date format
075: * @return birthDate
076: */
077: Date getBirthDate();
078:
079: /**
080: * The age in millseconds since this connection was built
081: */
082: long getAge();
083:
084: /**
085: * A unique ID for this connection
086: */
087: long getId();
088:
089: /**
090: * Sometimes we want do something to a connection but can't because it is still
091: * active and we don't want to disrupt its use. So we mark it instead and when it
092: * stops being active we can perform the necessary operation.
093: *
094: * The only thing we do at the moment is {@link #MARK_FOR_EXPIRY expire} the
095: * connection (if it is too old for instance). And this will happen if the
096: * housekeeper decides it should but the connection is still active.
097: */
098: int getMark();
099:
100: /**
101: * The status of the connection. Can be either:
102: * {@link #STATUS_NULL null},
103: * {@link #STATUS_AVAILABLE available},
104: * {@link #STATUS_ACTIVE active} or
105: * {@link #STATUS_OFFLINE offline}.
106: */
107: int getStatus();
108:
109: /**
110: * When this connection was last given out. The number of milliseconds
111: * since midnight, January 1, 1970 UTC.
112: */
113: long getTimeLastStartActive();
114:
115: /**
116: * When this connection was last given back (or zero if it is still active).
117: * The number of milliseconds
118: * since midnight, January 1, 1970 UTC.
119: */
120: long getTimeLastStopActive();
121:
122: /**
123: * The name of the thread that asked for this connection.
124: */
125: String getRequester();
126:
127: /**
128: * The hashcode (in hex) of the ProxyConnection object. This
129: * uniquely identifies this proxy connection.
130: * @return proxyHashcode
131: */
132: String getProxyHashcode();
133:
134: /**
135: * The hashcode (in hex) of the delegate connection object. This
136: * uniquely identifies the underlying connection.
137: * @return delegateHashcode
138: */
139: String getDelegateHashcode();
140:
141: /**
142: * The URL that this connection is using (the definition
143: * might have changed since this connection was built).
144: * @return delegateUrl
145: */
146: String getDelegateUrl();
147:
148: /**
149: * A log of the last SQL used on this connection. Only populated
150: * if {@link org.logicalcobwebs.proxool.ConnectionPoolDefinitionIF#isTrace()}
151: * is enabled.
152: * @return the most recent SQL to be used
153: */
154: String[] getSqlCalls();
155:
156: }
157:
158: /*
159: Revision history:
160: $Log: ConnectionInfoIF.java,v $
161: Revision 1.12 2005/10/07 08:18:23 billhorsman
162: 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)
163:
164: Revision 1.11 2005/09/26 10:01:31 billhorsman
165: Added lastSqlCall when trace is on.
166:
167: Revision 1.10 2003/10/30 00:05:50 billhorsman
168: now implements Comparable (using ID)
169:
170: Revision 1.9 2003/03/03 11:11:57 billhorsman
171: fixed licence
172:
173: Revision 1.8 2003/02/12 12:28:27 billhorsman
174: added url, proxyHashcode and delegateHashcode to
175: ConnectionInfoIF
176:
177: Revision 1.7 2003/01/31 11:38:57 billhorsman
178: birthDate now stored as Date not long
179:
180: Revision 1.6 2003/01/27 18:26:35 billhorsman
181: refactoring of ProxyConnection and ProxyStatement to
182: make it easier to write JDK 1.2 patch
183:
184: Revision 1.5 2003/01/15 00:12:13 billhorsman
185: doc
186:
187: Revision 1.4 2002/12/15 19:21:42 chr32
188: Changed @linkplain to @link (to preserve JavaDoc for 1.2/1.3 users).
189:
190: Revision 1.3 2002/10/25 16:00:19 billhorsman
191: added better class javadoc
192:
193: Revision 1.2 2002/09/18 13:48:56 billhorsman
194: checkstyle and doc
195:
196: Revision 1.1.1.1 2002/09/13 08:12:32 billhorsman
197: new
198:
199: Revision 1.3 2002/06/28 11:19:47 billhorsman
200: improved doc
201:
202: */
|