public static synchronized void sessionDestroyed(HttpSessionEvent ev) { HttpSession httpSession = ev.getSession(); String id = httpSession.getId(); synchronized (lookupSessionById) { lookupSessionById.remove(id); } // Forget HTTP-session: { lookupHttpSessionById.remove(id); } }
public static synchronized void sessionCreated(HttpSessionEvent ev) { HttpSession httpSession = ev.getSession(); String id = httpSession.getId(); // Remember HTTP-session: { lookupHttpSessionById.put(id, httpSession); } AbstractSession session = null; synchronized (lookupSessionById) { session = lookupSessionById.get(id); } if (session == null) { Principal userPrincipal = null; Date timeCreation = new Date(httpSession.getCreationTime()); Date timeLastAccess = new Date(httpSession.getLastAccessedTime()); List<String> urisForLastRequests = null; Properties properties = null; session = new DefaultSession( id, userPrincipal, timeCreation, timeLastAccess, urisForLastRequests, properties); synchronized (lookupSessionById) { lookupSessionById.put(id, session); // Update 'sessionCountMax': { int sessionCount = lookupSessionById.size(); if (sessionCount > sessionCountMax) { sessionCountMax = sessionCount; sessionCountMaxTime = System.currentTimeMillis(); } } } } }
protected void expandSession(AbstractSession session) throws IOException { if (session != null) { String id = session.getId(); HttpSession httpSession = lookupHttpSessionById.get(id); // Set 'timeLastAccess' upon session: { if (httpSession != null) { Date timeLastAccess = new Date(httpSession.getLastAccessedTime()); session.setTimeLastAccess(timeLastAccess); } } expandSessionPrincipal(session); // Set 'requestURI' upon session: { if (httpSession != null) { List<String> requestURIs = RequestURISessionDecorator.getRequestURIs(httpSession); if (requestURIs != null) { Collections.reverse(requestURIs); // reverse the order! session.setRequestURIs(requestURIs); } } } // Set 'properties' upon session: { if (httpSession != null) { Map<String, Object> m = PropertiesSessionDecorator.getProperties(httpSession); if (m != null) { Properties properties = convertProperties(m); session.setProperties(properties); } } } } }