public ConnectionPool getConnectionPool() { return (ConnectionPool)getSource(); } }
/** * Fires a ConnectionPoolEvent.POOL_RELEASED event to all listeners. * This method performs the listener notification synchronously to ensure * all listeners receive the event before the event-dispatch thread is * shutdown. */ private void firePoolReleasedEvent() { if (listeners.isEmpty()) return; ConnectionPoolEvent poolEvent = new ConnectionPoolEvent(this, ConnectionPoolEvent.Type.POOL_RELEASED); // No copy of listeners needs to be taken as the collection is thread-safe. for (ConnectionPoolListener listener : listeners) { try { listener.poolReleased(poolEvent); } catch (RuntimeException rx) { log_warn("Exception thrown by listener on pool release", rx); } } }
switch (evt.getType())
/** * Fires an ConnectionPoolEvent to all listeners. * 'type' should be one of ConnectionPoolEvent types. */ private void firePoolEvent(ConnectionPoolEvent.Type type) { if (listeners.isEmpty()) return; ConnectionPoolEvent poolEvent = new ConnectionPoolEvent(this, type); // Setup event dispatch thread if necessary. if (eventDispatcher == null) { eventDispatcher = new EventDispatcher<>(listeners, new Notifier()); eventDispatcher.start(); } // Dispatch event. eventDispatcher.dispatchEvent(poolEvent); }