/** start the connection manager. */ public void start() { if (!_lifecycle.toActive()) return; if (0 < _idleTimeout && _idleTimeout < 1000) _alarm.queue(1000); else if (1000 < _idleTimeout && _idleTimeout < 60000) _alarm.queue(_idleTimeout); else _alarm.queue(60000); }
/** Alarm listener. */ @Override public void handleAlarm(Alarm alarm) { if (!_lifecycle.isActive()) return; try { _alarmConnections.clear(); synchronized (_connectionPool) { _alarmConnections.addAll(_connectionPool); } for (int i = _alarmConnections.size() - 1; i >= 0; i--) { ManagedPoolItem item = _alarmConnections.get(i); if (!item.isValid()) item.destroy(); } _alarmConnections.clear(); fillIdlePool(); } finally { if (!_lifecycle.isActive()) { } else if (0 < _idleTimeout && _idleTimeout < 1000) _alarm.queue(1000); else if (1000 < _idleTimeout && _idleTimeout < 60000) _alarm.queue(_idleTimeout); else _alarm.queue(60000); } }
/** Stops the manager. */ public void stop() { if (!_lifecycle.toStop()) return; log.finer(this + " stopping"); if (_alarm != null) _alarm.dequeue(); }