org.logicalcobwebs.proxool
public class CompositeConnectionListener extends AbstractListenerContainer implements ConnectionListenerIF
ConnectionListenerIF
that keeps a list of ConnectionListenerIF
s
and notifies them in a thread safe manner.
It also implements ListenerContainerIF
which provides methods for
adding
and
removing
listeners.FATAL_SQL_EXCEPTION_DETECTED, HOUSE_KEEPER_TEST_FAIL, MANUAL_EXPIRY, MAXIMUM_ACTIVE_TIME_EXPIRED, MAXIMUM_CONNECTION_LIFETIME_EXCEEDED, RESET_FAIL, SHUTDOWN, VALIDATION_FAIL
Constructor and Description |
---|
CompositeConnectionListener() |
Modifier and Type | Method and Description |
---|---|
void |
onBirth(java.sql.Connection connection)
Happens everytime we create a new connection.
|
void |
onDeath(java.sql.Connection connection,
int reasonCode)
Happens just before we expire a connection.
|
void |
onExecute(java.lang.String command,
long elapsedTime)
Happens after every successful execute.
|
void |
onFail(java.lang.String command,
java.lang.Exception exception)
Happens everytime an exception was thrown during an execute method
Note that the command
is not fully implemented at this stage.
|
addListener, getListeners, isEmpty, removeListener
public void onBirth(java.sql.Connection connection) throws java.sql.SQLException
ConnectionListenerIF
onBirth
in interface ConnectionListenerIF
connection
- the connection that has just been createdjava.sql.SQLException
- if anything goes wrong (which will then be logged but ignored)ConnectionListenerIF.onBirth(Connection)
public void onDeath(java.sql.Connection connection, int reasonCode) throws java.sql.SQLException
ConnectionListenerIF
onDeath
in interface ConnectionListenerIF
connection
- the connection that is about to expirereasonCode
- ConnectionListenerIF.MAXIMUM_ACTIVE_TIME_EXPIRED
,
ConnectionListenerIF.HOUSE_KEEPER_TEST_FAIL
,
ConnectionListenerIF.FATAL_SQL_EXCEPTION_DETECTED
,
ConnectionListenerIF.MANUAL_EXPIRY
,
ConnectionListenerIF.MAXIMUM_CONNECTION_LIFETIME_EXCEEDED
,
ConnectionListenerIF.RESET_FAIL
,
ConnectionListenerIF.SHUTDOWN
, or
ConnectionListenerIF.VALIDATION_FAIL
java.sql.SQLException
- if anything goes wrong (which will then be logged but ignored)ConnectionListenerIF.onDeath(java.sql.Connection, int)
public void onExecute(java.lang.String command, long elapsedTime)
ConnectionListenerIF
onExecute
in interface ConnectionListenerIF
command
- what command was being executedelapsedTime
- how long the call took (in milliseconds)ConnectionListenerIF.onExecute(String, long)
public void onFail(java.lang.String command, java.lang.Exception exception)
ConnectionListenerIF
onFail
in interface ConnectionListenerIF
command
- what command was being executedexception
- what exception was thrownConnectionListenerIF.onFail(String, Exception)