onlinelist.java

来自「一个专门用来快速开发网站的框架」· Java 代码 · 共 60 行

JAVA
60
字号
package com.ksgl.body.member;/** * <p>Title: literature item </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2007</p> * <p>Company: </p> * @author hj * @version 1.0 */import javax.servlet.*;import javax.servlet.http.*;import java.util.*;import org.apache.commons.logging.LogFactory;import org.apache.commons.logging.Log;import com.ksgl.map.*;public class OnlineList implements HttpSessionAttributeListener {    private static Log log = LogFactory.getLog(OnlineList.class);    private static List list = new ArrayList();    public void attributeAdded(HttpSessionBindingEvent se) {        if ("user".equals(se.getName())) {//            log.info(((T_sys_user)se.getValue()).getName() + "登陆++");            list.add(se.getValue());        }    }    public void attributeRemoved(HttpSessionBindingEvent se) {        if ("user".equals(se.getName())) {//            log.info(((T_sys_user)se.getValue()).getName() + "离线--");            list.remove(se.getValue());        }    }    public void attributeReplaced(HttpSessionBindingEvent se) {        if ("user".equals(se.getName())) {//            log.info(((T_sys_user)se.getValue()).getName() + "Replaced--");            list.remove(se.getValue());        }    }    public static List getList() {        return (list);    }    public static int getActiveSessions() {        return list.size();    }    public static void userRemoved(UserInfo user) {        if(list.contains(user)){            log.info(user.getStrUserName() + "离线");            list.remove(user);        }    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?