Methods Summary |
---|
public int | getActiveSessions()Gets the number of active sessions that are being tracked.
return count;
|
public java.lang.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.
return trackedSessionId;
|
public synchronized void | reset()Resets this session tracker.
count = 0;
trackedSessionId = null;
contextNames.clear();
|
public void | sessionEvent(org.apache.catalina.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.
if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())) {
return;
}
Session session = event.getSession();
synchronized (this) {
if (session.getIdInternal() != null
&& session.getIdInternal().equals(trackedSessionId)
&& session.getManager() != null
&& session.getManager().getContainer() != null
&& contextNames.contains(
session.getManager().getContainer().getName())) {
count--;
if (count == 0) {
trackedSessionId = null;
if (response != null) {
response.removeSessionCookies();
}
}
}
session.removeSessionListener(this);
}
|
public synchronized void | setResponse(CoyoteResponse 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.
this.response = response;
|
public synchronized void | track(org.apache.catalina.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.
if (trackedSessionId == null) {
trackedSessionId = session.getIdInternal();
} else if (!trackedSessionId.equals(session.getIdInternal())) {
throw new IllegalArgumentException("Should never reach here");
}
count++;
if (session.getManager() != null
&& session.getManager().getContainer() != null
&& session.getManager().getContainer().getName() != null) {
contextNames.add(session.getManager().getContainer().getName());
}
session.addSessionListener(this);
|