/** * 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); }