@Override public boolean action(InternalSession is, Map<String, Long> sessions) { String nextExpiringSessionID = null; long smallestExpTime = Long.MAX_VALUE; for (Map.Entry<String, Long> entry : sessions.entrySet()) { String sid = entry.getKey(); long expirationTime = entry.getValue(); if (expirationTime < smallestExpTime) { smallestExpTime = expirationTime; nextExpiringSessionID = sid; } } if (nextExpiringSessionID != null) { SessionID sessID = new SessionID(nextExpiringSessionID); try { Session s = sessionCache.getSession(sessID); s.destroySession(s); } catch (SessionException e) { if (debug.messageEnabled()) { debug.message("Failed to destroy the next " + "expiring session.", e); } // deny the session activation request // in this case return true; } } return false; }