01: /*
02: * $Id: ConnectionMonitor.java,v 1.5 2002/09/16 08:05:03 jkl Exp $
03: *
04: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
05: *
06: * Use is subject to license terms, as defined in
07: * Anvil Sofware License, Version 1.1. See LICENSE
08: * file, or http://njet.org/license-1.1.txt
09: */
10: package anvil.database;
11:
12: /**
13: * Interface for monitoring events related to connections.
14: *
15: * @version $Revision: 1.5 $
16: * @author Jani Lehtimäki
17: */
18: public interface ConnectionMonitor {
19:
20: /**
21: * Initializes the monitor, called after the manager has
22: * been started up.
23: *
24: * @param pool Instance of connection pool
25: */
26: public void initialize(ConnectionPool pool);
27:
28: /**
29: * Notifies creation of connection. Upon notification
30: * connection is considered pending, not yet reserved.
31: *
32: * @param connection PooledConnection
33: * @param duration Duration of operation, in milliseconds
34: */
35: public void connectionCreated(PooledConnection connection,
36: long duration);
37:
38: /**
39: * Notifies reservation of connection immediately after operation
40: * has been performed.
41: *
42: * @param connection PooledConnection
43: * @param duration Duration of operation, in milliseconds
44: */
45: public void connectionReserved(PooledConnection connection,
46: long duration);
47:
48: /**
49: * Notifies unsuccessful attempt to acquire connection.
50: * Maximum timeout for acquire operation has been exceed.
51: *
52: * @param pool ConnectionPool
53: * @param duration Duration of operation, in milliseconds
54: */
55: public void connectionAcquireTimedout(ConnectionPool pool,
56: long duration);
57:
58: /**
59: * Notifies release of connection immediately after operation
60: * has been performed.
61: *
62: * @param connection PooledConnection
63: * @param duration Duration of operation, in milliseconds
64: */
65: public void connectionReleased(PooledConnection connection);
66:
67: /**
68: * Notifies that connection is being closed, because maximum lifetime
69: * has been exceeded or <code>java.sql.Connection</code> instance has been
70: * expliticly closed (for instance with <code>java.sql.Connection.close()</code>).
71: *
72: * @param connection PooledConnection
73: */
74: public void connectionClosed(PooledConnection connection);
75:
76: /**
77: * Notifies that the maximum reservation time of connection
78: * has been exceed. Thus the reserving thread is considered
79: * <i>dead</i> and connection has been a subject to forced
80: * shutdown.
81: *
82: * @param connection PooledConnection
83: */
84: public void connectionTimeout(PooledConnection connection);
85:
86: /**
87: * Notifies exception situation.
88: *
89: * @param source Informative source name (<i>class.method</i>)
90: * @param exception Exception that occured
91: */
92: public void connectionException(String source, Exception exception);
93: }
|