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:
011: /**
012: * You can listen to the lifecycle of a connection. Sometimes, you may
013: * want to perform a task when the connection is born or dies. Actually,
014: * the reason why we originally did this is now obsolete. But the code
015: * remains here just in case. You need to
016: * {@link ProxoolFacade#setConnectionListener register}
017: * your implementation with ProxoolFacade.
018: *
019: * <pre>
020: * String alias = "myPool";
021: * ConnectionListenerIF myConnectionListener = new MyConnectionListener();
022: * ProxoolFacade.{@link org.logicalcobwebs.proxool.ProxoolFacade#addConnectionListener addConnectionListener}(alias, myConnectionListener);
023: * </pre>
024: *
025: * @version $Revision: 1.7 $, $Date: 2003/03/03 11:11:57 $
026: * @author billhorsman
027: * @author $Author: billhorsman $ (current maintainer)
028: */
029: public interface ConnectionListenerIF {
030:
031: /**
032: * Happens everytime we create a new connection. You can use this
033: * to allocate resources to a connection that might be useful during
034: * the lifetime of the connection.
035: *
036: * @param connection the connection that has just been created
037: * @throws SQLException if anything goes wrong (which will then be logged but ignored)
038: */
039: void onBirth(Connection connection) throws SQLException;
040:
041: /**
042: * Happens just before we expire a connection. You can use this to
043: * reclaim resources from a connection.
044: *
045: * @param connection the connection that is about to expire
046: * @throws SQLException if anything goes wrong (which will then be logged but ignored)
047: */
048: void onDeath(Connection connection) throws SQLException;
049:
050: /**
051: * Happens after every successful execute. Note that the command
052: * is not fully implemented at this stage. At some point it might represent
053: * the SQL that is sent to the database (or the procedure call that was used).
054: *
055: * @param command what command was being executed
056: * @param elapsedTime how long the call took (in milliseconds)
057: */
058: void onExecute(String command, long elapsedTime);
059:
060: /**
061: * Happens everytime an exception was thrown during an execute method
062: * Note that the command
063: * is not fully implemented at this stage. At some point it might represent
064: * the SQL that is sent to the database (or the procedure call that was used).
065: *
066: * @param command what command was being executed
067: * @param exception what exception was thrown
068: */
069: void onFail(String command, Exception exception);
070:
071: }
072:
073: /*
074: Revision history:
075: $Log: ConnectionListenerIF.java,v $
076: Revision 1.7 2003/03/03 11:11:57 billhorsman
077: fixed licence
078:
079: Revision 1.6 2003/02/08 00:35:30 billhorsman
080: doc
081:
082: Revision 1.5 2002/12/15 19:21:42 chr32
083: Changed @linkplain to @link (to preserve JavaDoc for 1.2/1.3 users).
084:
085: Revision 1.4 2002/10/25 16:00:20 billhorsman
086: added better class javadoc
087:
088: Revision 1.3 2002/10/23 21:04:36 billhorsman
089: checkstyle fixes (reduced max line width and lenient naming convention
090:
091: Revision 1.2 2002/10/16 11:45:52 billhorsman
092: removed obsolete cleanupClob method and added more javadoc
093:
094: Revision 1.1.1.1 2002/09/13 08:12:34 billhorsman
095: new
096:
097: Revision 1.5 2002/08/24 19:43:04 billhorsman
098: new execute events
099:
100: Revision 1.4 2002/06/28 11:15:41 billhorsman
101: didn't really need ListenerIF
102:
103: */
|