|
楼主 |
发表于 2015-8-20 08:26:27
|
显示全部楼层
本帖最后由 davidhuang 于 2015-8-20 09:18 编辑
这是我的做法,测试好像通过了, 登录在AfterLogin处理,退出在BeforeLogout处理
public class System {
private static ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
public static void systemProcessAfterLoginAction() {
HttpSession session = ContextHelper.getSessionContext().getSession();
String userID = ContextHelper.getOperator().getID();
Object object = concurrentHashMap.get(userID);
if( object == null ){
concurrentHashMap.put(userID, session);
}else{
HttpSession session1 = (HttpSession)object;
concurrentHashMap.remove(userID);
session1.invalidate();
concurrentHashMap.put(userID, session);
}
}
public static void systemProcessBeforeLogoutAction() {
String userID = ContextHelper.getOperator().getID();
Object object = concurrentHashMap.get(userID);
concurrentHashMap.remove(userID);
HttpSession session1 = (HttpSession)object;
session1.invalidate();
concurrentHashMap.remove(userID);
}
}
|
|