Author: anil.saldhana(a)jboss.com
Date: 2009-10-27 19:20:21 -0400 (Tue, 27 Oct 2009)
New Revision: 882
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/core/IdentityServer.java
Log:
JBID-205: active sessions logged
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/core/IdentityServer.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/core/IdentityServer.java 2009-10-27
22:20:57 UTC (rev 881)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/core/IdentityServer.java 2009-10-27
23:20:21 UTC (rev 882)
@@ -21,6 +21,8 @@
*/
package org.jboss.identity.federation.web.core;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack;
@@ -31,6 +33,7 @@
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
+import org.apache.log4j.Logger;
import org.jboss.identity.federation.web.constants.GeneralConstants;
/**
@@ -40,6 +43,18 @@
*/
public class IdentityServer implements HttpSessionListener
{
+ private static Logger log = Logger.getLogger(IdentityServer.class);
+ private boolean trace = log.isTraceEnabled();
+
+ private static int count = AccessController.doPrivileged(new
PrivilegedAction<Integer>()
+ {
+ public Integer run()
+ {
+ String val = System.getProperty("identity.server.log.count",
"100");
+ return Integer.parseInt(val);
+ }
+ });
+
private static int activeSessionCount = 0;
private STACK stack = new STACK();
@@ -206,7 +221,15 @@
{
activeSessionCount++;
+ if(activeSessionCount % count == 0)
+ log.info("Active Session Count=" + activeSessionCount);
+
HttpSession session = sessionEvent.getSession();
+
+ if(trace)
+ log.trace("Session Created with id=" + session.getId() +
+ "::active session count=" + activeSessionCount);
+
//Ensure that the IdentityServer instance is set on the servlet context
ServletContext servletContext = session.getServletContext();
@@ -231,6 +254,11 @@
public void sessionDestroyed(HttpSessionEvent sessionEvent)
{
--activeSessionCount;
- stack.remove(sessionEvent.getSession().getId());
+
+ String id = sessionEvent.getSession().getId();
+ if(trace)
+ log.trace("Session Destroyed with id=" + id + "::active session
count="
+ + activeSessionCount);
+ stack.remove(id);
}
}
\ No newline at end of file
Show replies by date