*/
public class ConnectionPool {
- public static interface CloseListener {
- void poolClosed(ConnectionPool pool);
- }
-
//logger
protected static Log log = LogFactory.getLog(ConnectionPool.class);
//===============================================================================
// INSTANCE/QUICK ACCESS VARIABLE
//===============================================================================
- protected ConcurrentLinkedQueue<CloseListener> listeners = new ConcurrentLinkedQueue<CloseListener>();
-
/**
* All the information about the connection pool
*/
close(true);
}
- public void addCloseListener(CloseListener listener) {
- listeners.add(listener);
- }
-
- public void removeCloseListener(CloseListener listener) {
- listeners.remove(listener);
- }
-
/**
* Closes the pool and all disconnects all idle connections
* Active connections will be closed upon the {@link java.sql.Connection#close close} method is called
size.set(0);
if (this.getPoolProperties().isJmxEnabled()) stopJmx();
- while (listeners.size()>0) {
- CloseListener listener = listeners.poll();
- if (listener!=null) listener.poolClosed(this);
- }
} //closePool
protected int removeAbandonedTimeout = 60;
protected boolean logAbandoned = false;
protected int loginTimeout = 10000;
- protected String name = "Tomcat Connection Pool["+(poolCounter.addAndGet(1))+"]";
+ protected String name = "Tomcat Connection Pool["+(poolCounter.addAndGet(1))+","+System.identityHashCode(PoolProperties.class)+"]";
protected String password;
protected String username;
protected long validationInterval = 30000;
//============================================================================
-// com.filip.util.IPoolObject methods
+//
//============================================================================
public long getAbandonTimeout() {
* @author Filip Hanik
* @version 1.0
*/
-public class SlowQueryReport extends AbstractCreateStatementInterceptor implements ConnectionPool.CloseListener {
+public class SlowQueryReport extends AbstractCreateStatementInterceptor {
//logger
protected static Log log = LogFactory.getLog(SlowQueryReport.class);
/**
* the constructors that are used to create statement proxies
*/
- protected static final Constructor[] constructors = new Constructor[AbstractCreateStatementInterceptor.statements.length];
+ protected static final Constructor[] constructors =
+ new Constructor[AbstractCreateStatementInterceptor.statements.length];
/**
* we will be keeping track of query stats on a per pool basis, do we want this, or global?
*/
*/
@Override
public void closeInvoked() {
- queries = null;
+ try {
+ queries = null;
+ finalize();
+ pool = null;
+ }catch (Exception x) {
+ log.debug(x);
+ }
}
};
perPoolStats.put(parent, queries);
- //add ourselves to the pool listener, so we can cleanup
- parent.addCloseListener(this);
}
this.pool = parent;
}
public void finalize() {
- if (pool!=null) pool.removeCloseListener(this);
}
-
- public void poolClosed(ConnectionPool pool) {
- //clean up after ourselves.
- perPoolStats.remove(pool);
- }
-
public CompositeData[] getSlowQueriesCD() {
return null;
}