com.ths.csa
Class TrackedSession

com.ths.csa.TrackedSession

public class TrackedSession

Title: TrackedSession Description: object representing a session in the session tracking system Copyright: Copyright (c) 2001 Company: Techouse Software Co.


Field Summary
static java.io.PrintStream c_consoleMessages
           
 
Constructor Summary
TrackedSession()
           
 
Method Summary
protected  double calculateSessionDuration()
          Calculates the session duration based on the time of the last event.
protected  void checkForBackButton(javax.servlet.http.HttpServletRequest request)
          Checks for backbutton use by comparing the internal current request ID to the value pulled from request.getParameter(requestIDParmName).
protected  void fileSessionEvent(com.ths.csa.SessionEvent sessionEvent)
          Files the session event argument into the session events Vector.
 int getActiveSessionCount()
          Returns the number of tracked currently active sessions.
 int getCurrentRequestID()
          Returns the current request ID value.
 java.lang.String getRequestIDParameterName()
          Returns the request ID parameter name as set in the call to initialize()
 java.lang.String getServerName()
          Returns the server name handling this session.
protected  java.util.Vector getSessionEvents()
          Designed to be used by subclasses needing to override the persistData() method
 java.util.Date getStartTime()
          Returns the start Date of this session.
 int incrementCurrentRequestID()
          Increments the current internal request ID.
 void initialize(javax.servlet.http.HttpServletRequest request, java.lang.String appName, java.lang.String xmlStoragePath, java.lang.String requestIDParmName, java.io.PrintStream consoleMessages)
          Initializes this tracked session and increments the number of current active sessions.
 void persistData()
          Designed for extending TrackedSession by allowing custom behaviour.
 void recordBackButton(int backClicks)
          Creates and files a backbutton event.
 void recordLoginId(java.lang.String loginID)
          Records the visitor's login ID as session level data.
 void recordLogout()
          Creates and files a logout event.
 void recordNewPage(javax.servlet.http.HttpServletRequest request, java.lang.String pageName)
          Checks for backbutton use, then creates and files a page event.
 void recordPageData(java.lang.String key, java.lang.String value)
          Adds user defined data (key/value pair) to the last recorded event.
 void recordSessionAttribute(java.lang.String key, java.lang.String value)
          Records session-level user defined data (key/value pair).
protected  void recordSessionTimeout()
          Creates and files a session timeout event.
 void valueBound(com.ths.csa.HttpSessionBindingEvent event)
          For HttpSessionBindingListener Interface.
 void valueUnbound(com.ths.csa.HttpSessionBindingEvent event)
          For HttpSessionBindingListener Interface.
protected  void writeToXMLFile()
          Writes out the session contents as an XML file.
 

Field Detail

c_consoleMessages

public static java.io.PrintStream c_consoleMessages
Constructor Detail

TrackedSession

public TrackedSession()
Method Detail

initialize

public void initialize(javax.servlet.http.HttpServletRequest request,
                       java.lang.String appName,
                       java.lang.String xmlStoragePath,
                       java.lang.String requestIDParmName,
                       java.io.PrintStream consoleMessages)
Initializes this tracked session and increments the number of current active sessions.

recordNewPage

public void recordNewPage(javax.servlet.http.HttpServletRequest request,
                          java.lang.String pageName)
Checks for backbutton use, then creates and files a page event.

recordPageData

public void recordPageData(java.lang.String key,
                           java.lang.String value)
Adds user defined data (key/value pair) to the last recorded event. Keys cannot be null, contain spaces, or contain XML special characters. Values cannot be null.

recordBackButton

public void recordBackButton(int backClicks)
Creates and files a backbutton event. Used by CSA's internal backbutton checking, but made public for integration with other checking mechanisms.

recordLogout

public void recordLogout()
Creates and files a logout event.

checkForBackButton

protected void checkForBackButton(javax.servlet.http.HttpServletRequest request)
Checks for backbutton use by comparing the internal current request ID to the value pulled from request.getParameter(requestIDParmName).

valueBound

public void valueBound(com.ths.csa.HttpSessionBindingEvent event)
For HttpSessionBindingListener Interface. valueBound() is called before initialize() is called, so no class values have been set. Beware of doing anything a'tall in this method. Currently does nothing.

valueUnbound

public void valueUnbound(com.ths.csa.HttpSessionBindingEvent event)
For HttpSessionBindingListener Interface. Decrements active sessions count. Calls recordSessionTimeout() and persists the session to an XML file via persistData(), unless recordLogout() has been called previously.

persistData

public void persistData()
Designed for extending TrackedSession by allowing custom behaviour. Currently calls writeToXMLFile()

recordSessionTimeout

protected void recordSessionTimeout()
Creates and files a session timeout event.

recordSessionAttribute

public void recordSessionAttribute(java.lang.String key,
                                   java.lang.String value)
Records session-level user defined data (key/value pair). Keys cannot be null, contain spaces, or contain XML special characters. Values cannot be null.

incrementCurrentRequestID

public int incrementCurrentRequestID()
Increments the current internal request ID.

recordLoginId

public void recordLoginId(java.lang.String loginID)
Records the visitor's login ID as session level data.

fileSessionEvent

protected void fileSessionEvent(com.ths.csa.SessionEvent sessionEvent)
Files the session event argument into the session events Vector. Calculates the previous event's duration if the current event isn't a timeout.

writeToXMLFile

protected void writeToXMLFile()
Writes out the session contents as an XML file.

getSessionEvents

protected java.util.Vector getSessionEvents()
Designed to be used by subclasses needing to override the persistData() method

calculateSessionDuration

protected double calculateSessionDuration()
Calculates the session duration based on the time of the last event. Uses the last user event if the session ends by timeout.

getCurrentRequestID

public int getCurrentRequestID()
Returns the current request ID value.

getRequestIDParameterName

public java.lang.String getRequestIDParameterName()
Returns the request ID parameter name as set in the call to initialize()

getActiveSessionCount

public int getActiveSessionCount()
Returns the number of tracked currently active sessions.

getServerName

public java.lang.String getServerName()
Returns the server name handling this session.

getStartTime

public java.util.Date getStartTime()
Returns the start Date of this session.