计算活跃用户

时间:2010-09-29 04:21:20

标签: java spring spring-security

我正在使用spring security 2.

1.我可以知道如何使用securitycontextholder获取活跃用户总数吗?
2.可以从securitycontextholder中检索sessionregistry吗?

2 个答案:

答案 0 :(得分:3)

延长AuthenticationProcessingFilter

覆盖

@Override
    protected void onSuccessfulAuthentication(HttpServletRequest request,
            HttpServletResponse response, Authentication authResult)
            throws IOException {  

在这里,您可以通过保留应用程序变量来完成您想要做的事情。

答案 1 :(得分:1)

我不知道怎么做春天。但是在servlet中,您需要为侦听器类实现HttpSession Listener接口。该接口有两个方法,即sessionCreated()和sessionDestroyed()。每当创建新会话时,您都可以在方法sessionCreated中增加静态变量。

相关问题