Package org.apache.catalina.connector
Class SessionTracker
- java.lang.Object
-
- org.apache.catalina.connector.SessionTracker
-
- All Implemented Interfaces:
SessionListener
public class SessionTracker extends Object implements SessionListener
Class responsible for keeping track of the total number of active sessions associated with an HTTP request.A given HTTP request may be associated with more than one active session if it has been dispatched to one or more foreign contexts.
The number of active sessions being tracked is used to determine whether or not any session information needs to be reflected in the response (e.g., in the form of a response cookie). If no active sessions are associated with the request by the time the response is committed, no session information will be reflected in the response. See GlassFish Issue 896 for additional details.
-
-
Constructor Summary
Constructors Constructor Description SessionTracker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetActiveSessions()Gets the number of active sessions that are being tracked.StringgetSessionId()Gets the id of the sessions that are being tracked.voidreset()Resets this session tracker.voidsessionEvent(SessionEvent event)Processes the given session event, by unregistering this SessionTracker as a session listener from the session that is the source of the event, and by decrementing the counter of currently tracked sessions.voidsetResponse(Response response)Associates the given response with this SessionTracker.voidtrack(Session session)Tracks the given session, by registering this SessionTracker as a listener with the given session, and by incrementing the counter of currently tracked sessions.
-
-
-
Method Detail
-
sessionEvent
public void sessionEvent(SessionEvent event)
Processes the given session event, by unregistering this SessionTracker as a session listener from the session that is the source of the event, and by decrementing the counter of currently tracked sessions.- Specified by:
sessionEventin interfaceSessionListener- Parameters:
event- The session event
-
getActiveSessions
public int getActiveSessions()
Gets the number of active sessions that are being tracked.- Returns:
- The number of active sessions being tracked
-
getSessionId
public String getSessionId()
Gets the id of the sessions that are being tracked. Notice that since all sessions are associated with the same request, albeit in different context, they all share the same id.- Returns:
- The id of the sessions that are being tracked
-
track
public void track(Session session)
Tracks the given session, by registering this SessionTracker as a listener with the given session, and by incrementing the counter of currently tracked sessions.- Parameters:
session- The session to track
-
setResponse
public void setResponse(Response response)
Associates the given response with this SessionTracker. If the number of tracked sessions drops to zero, this SessionTracker will remove the Set-Cookie from the given response.- Parameters:
response- The response from which to remove the Set-Cookie header if the number of tracked sessions drops to zero
-
reset
public void reset()
Resets this session tracker.
-
-