Package com.jalios.jcms
Class JcmsSessionTracker
- java.lang.Object
-
- com.jalios.jcms.JcmsSessionTracker
-
public class JcmsSessionTracker extends java.lang.Object
This singleton class tracks sessions of guest and logged members in JCMS.- Version:
- $Revision: 107554 $
- Author:
- Olivier Dedieu, Olivier Jaquemet
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
IGNORE_SESSION
It is possible to specify the session must not be registered, by setting the request attribute with this key and Boolean.TRUE as value.static java.lang.String
REVISION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addTrace(javax.servlet.http.HttpSession session, java.util.HashMap<java.lang.String,java.lang.Object> trace)
Add a new trace to the given HttpSession.static int
getAllSessionCount()
Returns the count of sessions, that is, getLoggedMemberSet().size() + getUnauthenticatedCount()static java.util.Set<Member>
getLoggedMemberSet()
Returns the set of member who have a valid session where there are logged.static int
getLoggedSessionCount()
Returns the number of logged sessionstatic int
getMaxTraceNbr()
static int
getMemberSessionCount(Member member)
Returns the number of logged session for a given member.static java.util.HashMap<java.lang.String,java.util.LinkedList<java.util.HashMap<java.lang.String,java.lang.Object>>>
getMemberSessionIdTraceMap(Member mbr)
Retrieve all traces associated with a given member.static java.util.LinkedList<java.util.HashMap<java.lang.String,java.lang.Object>>
getTraceList(java.lang.String sessionId)
Return a ArrayList (a copy) of the traces (HashMap) of the HttpSession corresponding to the given session id.static java.util.LinkedList<java.util.HashMap<java.lang.String,java.lang.Object>>
getTraceList(javax.servlet.http.HttpSession session)
Return a LinkedList (a copy) of the traces (HashMap) of the given HttpSession.static int
getUnauthenticatedCount()
Returns the count of unauthenticated session (including normal clients and robots).static int
getUnauthenticatedNonRobotCount()
Returns the count of unauthenticated session which are not from robots.static int
getUnauthenticatedRobotCount()
Returns the count of unauthenticated session which are from robots.static boolean
isLogged(Member member)
Returns true if the given member has a valid logged sessionstatic void
logDebugInformation()
static boolean
removeMemberFromSessionTracker(Member mbr)
Remove the given member from the session tracker.static void
removeSession(javax.servlet.http.HttpSession session)
Remove the given session from the JCMS session tracker.static void
setMaxTraceNbr(int maxTraceNbr)
Set the maximum number of trace to keep per session, default value is 0.static void
trackSession(javax.servlet.http.HttpSession session, Member loggedMember)
Enable tracking for this session.static void
update(javax.servlet.http.HttpSession session, Member member)
Associate a member to a given session (using its ID) in the JCMS session tracker.
-
-
-
Field Detail
-
REVISION
public static final java.lang.String REVISION
- See Also:
- Constant Field Values
-
IGNORE_SESSION
public static final java.lang.String IGNORE_SESSION
It is possible to specify the session must not be registered, by setting the request attribute with this key and Boolean.TRUE as value.- See Also:
- Constant Field Values
-
-
Method Detail
-
logDebugInformation
public static void logDebugInformation()
-
trackSession
public static void trackSession(javax.servlet.http.HttpSession session, Member loggedMember)
Enable tracking for this session.- Parameters:
session
- the HttpSession to trackloggedMember
- the Member logged for this session
-
removeSession
public static void removeSession(javax.servlet.http.HttpSession session)
Remove the given session from the JCMS session tracker.- Parameters:
session
- the session to remove from the session tracker.
-
update
public static void update(javax.servlet.http.HttpSession session, Member member)
Associate a member to a given session (using its ID) in the JCMS session tracker.- Parameters:
session
- the member's HttpSessionmember
- the logged member in the given session (null if no authenticated member)
-
getMaxTraceNbr
public static int getMaxTraceNbr()
- Returns:
- the current maximum number of trace allowed, default value is 0.
-
setMaxTraceNbr
public static void setMaxTraceNbr(int maxTraceNbr)
Set the maximum number of trace to keep per session, default value is 0.- Parameters:
maxTraceNbr
- specify the maximum number as follow- < 0 : Save all trace (warning: can really be memory consumming).
- = 0 : Do not save any trace.
- > 0 : Save n trace.
-
addTrace
public static void addTrace(javax.servlet.http.HttpSession session, java.util.HashMap<java.lang.String,java.lang.Object> trace)
Add a new trace to the given HttpSession. Keep as many trace as specified by the value MaxTraceNbr.- Parameters:
session
- the HttpSession in which to add a tracetrace
- a HashMap containing any
-
getTraceList
public static java.util.LinkedList<java.util.HashMap<java.lang.String,java.lang.Object>> getTraceList(javax.servlet.http.HttpSession session)
Return a LinkedList (a copy) of the traces (HashMap) of the given HttpSession.- Parameters:
session
- the HttpSession of which you want to get trace- Returns:
- a LinkedList of HashMap
-
getTraceList
public static java.util.LinkedList<java.util.HashMap<java.lang.String,java.lang.Object>> getTraceList(java.lang.String sessionId)
Return a ArrayList (a copy) of the traces (HashMap) of the HttpSession corresponding to the given session id.- Parameters:
sessionId
- the session id of the HttpSession of which you want to get trace- Returns:
- an ArrayList of HashMap
-
getMemberSessionIdTraceMap
public static java.util.HashMap<java.lang.String,java.util.LinkedList<java.util.HashMap<java.lang.String,java.lang.Object>>> getMemberSessionIdTraceMap(Member mbr)
Retrieve all traces associated with a given member.- Parameters:
mbr
- the member whom to find traces.- Returns:
- an HashMap with the session Id as the key, and an ArrayList of the traces (HashMap) as the value.
-
removeMemberFromSessionTracker
public static boolean removeMemberFromSessionTracker(Member mbr)
Remove the given member from the session tracker. Do not call this if not really needed! This method is available to allow deletion of a member. Should not be call elsewhere.- Parameters:
mbr
- the member to remove- Returns:
true
if member was removed, false if it was not in session tracker
-
getLoggedMemberSet
public static java.util.Set<Member> getLoggedMemberSet()
Returns the set of member who have a valid session where there are logged.- Returns:
- a set of member
-
getUnauthenticatedCount
public static int getUnauthenticatedCount()
Returns the count of unauthenticated session (including normal clients and robots).- Returns:
- the count of unauthenticated session (including normal clients and robots).
-
getUnauthenticatedNonRobotCount
public static int getUnauthenticatedNonRobotCount()
Returns the count of unauthenticated session which are not from robots.- Returns:
- the count of unauthenticated session which are not from robots.
-
getUnauthenticatedRobotCount
public static int getUnauthenticatedRobotCount()
Returns the count of unauthenticated session which are from robots.- Returns:
- the count of unauthenticated session which are from robots.
-
getAllSessionCount
public static int getAllSessionCount()
Returns the count of sessions, that is, getLoggedMemberSet().size() + getUnauthenticatedCount()- Returns:
- the count of sessions
-
getLoggedSessionCount
public static int getLoggedSessionCount()
Returns the number of logged session- Returns:
- the number of logged session (greater or equals to logged members)
-
isLogged
public static boolean isLogged(Member member)
Returns true if the given member has a valid logged session- Parameters:
member
- the member to check- Returns:
- true if the given member has a valid logged session
-
getMemberSessionCount
public static int getMemberSessionCount(Member member)
Returns the number of logged session for a given member. A same member can have severals open session if :- He browses with several browser (IE, Netscape, Opera). One session by browser.
- He browses from several computers. One session by browser by computer.
- He browses from one compture with the same browser but use different browser profiles.
- Parameters:
member
- the member to check- Returns:
- the number of logged session
-
-