?? sessiontracker.java
字號:
package org.ssi.Listener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class SessionTracker implements HttpSessionListener {
private static Map activeSessions = new HashMap();
public void sessionCreated(HttpSessionEvent event) {
HttpSession session = event.getSession();
synchronized (activeSessions) {
activeSessions.put(session.getId(), session);
}
}
public void sessionDestroyed(HttpSessionEvent event) {
HttpSession session = event.getSession();
synchronized (activeSessions) {
activeSessions.remove(session.getId());
}
}
public static void closeAllSessions() {
synchronized (activeSessions) {
for (Iterator i = activeSessions.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
String sessionId = (String) entry.getKey();
HttpSession session = (HttpSession) entry.getValue();
session.invalidate();
i.remove();
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -