sky.common.session
Class BaseTracker

java.lang.Object
  extended bysky.common.session.BaseTracker
All Implemented Interfaces:
Tracker

public class BaseTracker
extends java.lang.Object
implements Tracker

This class keeps track of various user sessions that are initiated. Besides monitoring all the session information, the Tracker also provides an API that can be used to access information on each of the sessions that are being tracked. The tracker can also persist sessions to a database or a file.

$RCSfile: BaseTracker.java,v $
$Revision: 1.2 $, $Date: 2005/04/24 03:14:00 $


Field Summary
protected  boolean _active
          true if tracker is running; otherwise, false.
protected  int _max
          Maximum limit on number of sessions that are being tracked.
protected  java.util.Hashtable _sessions
          Sessions being tracked currently.
protected  long _timeout
          Time interval after which an idling session is dropped and not tracked any more.
 
Constructor Summary
BaseTracker(int max, long timeout)
          Constructor
 
Method Summary
 void activate()
          Starts the tracker.
 void deactivate()
          Stops the tracker.
 int getSessionCount()
          Gets number of sessions that are currently being tracked.
 java.util.Enumeration getSessionIds()
          Gets the ids of all sessions that are being tracked.
 java.util.Enumeration getSessionObj()
          Gets all the sessions that are being tracked.
 Session getSessionObj(java.lang.String id)
          Gets a session object with given id.
 boolean isActive()
          Checks if tracker is active.
 void reset()
          Resets the tracker and clears all state information.
 void track(java.lang.String id, java.lang.String ip, Event event)
          Add an event to a perticular session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_max

protected int _max
Maximum limit on number of sessions that are being tracked.


_timeout

protected long _timeout
Time interval after which an idling session is dropped and not tracked any more.


_active

protected boolean _active
true if tracker is running; otherwise, false.


_sessions

protected java.util.Hashtable _sessions
Sessions being tracked currently. Hash key is session id while value is Session object itself.

Constructor Detail

BaseTracker

public BaseTracker(int max,
                   long timeout)
Constructor

Parameters:
max - maximum number of sessions that will be tracked at any given time.
timeout - time interval after which an idling session will no longer be tracked.
Method Detail

activate

public void activate()
Starts the tracker.

Specified by:
activate in interface Tracker

deactivate

public void deactivate()
Stops the tracker.

Specified by:
deactivate in interface Tracker

isActive

public boolean isActive()
Checks if tracker is active.

Specified by:
isActive in interface Tracker
Returns:
true if tracker is active; otherwise, false.

reset

public void reset()
Resets the tracker and clears all state information.

Specified by:
reset in interface Tracker

getSessionIds

public java.util.Enumeration getSessionIds()
Gets the ids of all sessions that are being tracked.

Specified by:
getSessionIds in interface Tracker
Returns:
Enumeration of session id strings.

getSessionObj

public java.util.Enumeration getSessionObj()
Gets all the sessions that are being tracked.

Specified by:
getSessionObj in interface Tracker
Returns:
Enumeration of all session objects.

getSessionObj

public Session getSessionObj(java.lang.String id)
Gets a session object with given id.

Specified by:
getSessionObj in interface Tracker
Returns:
session object.

getSessionCount

public int getSessionCount()
Gets number of sessions that are currently being tracked.

Specified by:
getSessionCount in interface Tracker
Returns:
session count.

track

public void track(java.lang.String id,
                  java.lang.String ip,
                  Event event)
Add an event to a perticular session. If the session does not exist then this is the first event of the session, so a new session is created.

Specified by:
track in interface Tracker
Parameters:
id - unique id of a new or existing session.
ip - ip address where this session originted from.
event - Event that occured.