⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countlistener.java

📁 版本信息:Jaoso新闻文章发布系统 0.9.1beta1 原POPTEN新闻发布系统现更名为Jaoso,不兼容popten,目前不提供popten升级Jaoso的程序.
💻 JAVA
字号:
package jaoso.count.web.listener;

import jaoso.count.service.CountService;

import jaoso.framework.service.ServiceLocator;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;


/**
 * @author 边缘孤客
 * 统计在线人数的监视器
 */
public class CountListener implements HttpSessionListener {

    //~ Static fields/initializers =============================================

    /**  在线人数 */
    private static int onlineCount = 0;

    //~ Instance fields ========================================================

    /**  统计服务 */
    private CountService countService = (CountService) ServiceLocator.getInstance()
                                                                     .getService("countService");

    //~ Methods ================================================================

    /**
     * (non-Javadoc)
     * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
     */
    public final void sessionCreated(final HttpSessionEvent arg0) {

        countService.getCount(true);
        onlineCount++;
    }

    /**
     * (non-Javadoc)
     * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
     */
    public final void sessionDestroyed(final HttpSessionEvent arg0) {

        if (onlineCount > 0) {
            onlineCount--;
        }
    }

    /**
     * @return Returns the onlineCount.
     */
    public static int getOnlineCount() {

        return onlineCount;
    }
}

⌨️ 快捷键说明

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