forked from psi-probe/psi-probe
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
psi-probe-core/src/main/java/psiprobe/SessionCounterListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Licensed under the GPL License. You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.gnu.org/licenses/old-licenses/gpl-2.0.html | ||
* | ||
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
* WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE. | ||
*/ | ||
package psiprobe; | ||
|
||
import javax.servlet.annotation.WebListener; | ||
import javax.servlet.http.HttpSessionEvent; | ||
import javax.servlet.http.HttpSessionListener; | ||
|
||
@WebListener | ||
public class SessionCounterListener implements HttpSessionListener { | ||
|
||
private static int totalActiveSessions; | ||
|
||
public static int getTotalActiveSession(){ | ||
return totalActiveSessions; | ||
} | ||
|
||
@Override | ||
public void sessionCreated(HttpSessionEvent arg0) { | ||
totalActiveSessions++; | ||
System.out.println("sessionCreated - add one session into counter"); | ||
} | ||
|
||
@Override | ||
public void sessionDestroyed(HttpSessionEvent arg0) { | ||
totalActiveSessions--; | ||
System.out.println("sessionDestroyed - deduct one session from counter"); | ||
} | ||
|
||
} |