Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.webapps.bean
Class Session  view Session download Session.java

java.lang.Object
  extended bycom.RuntimeCollective.webapps.bean.Session
All Implemented Interfaces:
EntityBean, java.io.Serializable

public class Session
extends java.lang.Object
implements EntityBean

The Session object is the identification that a User has logged in, and when.

It is particularly useful in conjunction with TrackedUsers. EditorCheckLogon supports it, but CheckLogon doesn't (yet).

It is recommended to use the updateSessionTag at the top of all JSP pages, for the Session to be kept up-to-date.

Version:
$Id: Session.java,v 1.16 2003/09/30 15:13:09 joe Exp $

Field Summary
private static java.lang.String AND
           
private static java.lang.String CLOSE
           
protected  java.util.Date createDate
          The date of the session
private static java.lang.String CREATION_DATE
           
static java.lang.String DATABASE_TABLE
          The name of the database table for this bean type.
private static java.lang.String DELETE_FROM
           
protected static java.text.SimpleDateFormat df
          The date format used.
static java.lang.String ENTITY_NAME
           
protected  int id
          The session id
private static java.lang.String LAST_USED
           
private static java.lang.String LAST_USED_DATE
           
protected  java.util.Date lastUsedDate
          The last used date of the session
private static java.lang.String LOGON_USER_KEY
           
private static java.lang.String SELECT_DATA
           
private static java.lang.String SELECT_ID
           
static java.lang.String SESSION_KEY
           
private static java.lang.String SET_LAST_USED_DATE
           
private static java.lang.String SPACE
           
private static java.lang.String SPACE_OPEN
           
protected  User theUser
          The session's User.
static java.lang.String TIMEOUT_KEY
           
static java.lang.String TIMEOUT_PAGE_KEY
           
protected  int timeout_span_millis
          No of millis until time out.
protected  int timeout_span_mins
          No of minutes until time out.
private static java.lang.String UPDATE
           
private static java.lang.String USER_ID
           
private static java.lang.String WHERE_ID
           
private static java.lang.String WHERE_T_ID
           
private static java.lang.String WHERE_USER
           
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
INTERFACE_BEAN, NULL_ID
 
Constructor Summary
Session()
          /* Called to make a new session.
Session(int id)
          Get a sesssion from the RuntimeDataSource, given an id.
 
Method Summary
 void delete()
          Tear down this session
static void deleteExpiredSessionsForUser(User user)
          Delete all expired Sessions for a given User.
 void doQuickUpdate()
          Update the last used date in the db, by hitting it only once.
static java.util.List getActiveSessionsList()
          Gets a List of all active session.
 java.util.Date getCreateDate()
          Get the date of the session
 java.lang.String getEntityName()
          Get the entity name of this entity bean, used to identify this bean within the EntityBeanStore.
 int getId()
          Get the session id
 java.util.Date getLastUsedDate()
          Get the date of the session
static int getNumberOfActiveSessions()
          Gets the number of active sessions, for all users.
 User getTheUser()
          Get the session's User.
static java.util.Iterator getUsersWithActiveSessions()
          Gets an Iterator of all active User beans in the system.
static java.util.List getUsersWithActiveSessionsAsList()
          Gets a List of all active User beans in the system.
 boolean hasTimedOut()
          Whether this Session has timed out.
static Session logUserIn(User user, javax.servlet.http.HttpServletRequest request)
          Log a user in to the website.
 void save()
          Save this session
 void setCreateDate(java.util.Date createDate)
          Set the date of the session
 void setId(int id)
          Set the session id
 void setLastUsedDate(java.util.Date lastUsedDate)
          Set the date of the session
 void setTheUser(User theUser)
          Set the session's User.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATABASE_TABLE

public static final java.lang.String DATABASE_TABLE
The name of the database table for this bean type.

See Also:
Constant Field Values

ENTITY_NAME

public static java.lang.String ENTITY_NAME

SESSION_KEY

public static java.lang.String SESSION_KEY

TIMEOUT_KEY

public static java.lang.String TIMEOUT_KEY

TIMEOUT_PAGE_KEY

public static java.lang.String TIMEOUT_PAGE_KEY

SELECT_DATA

private static final java.lang.String SELECT_DATA
See Also:
Constant Field Values

DELETE_FROM

private static final java.lang.String DELETE_FROM
See Also:
Constant Field Values

WHERE_ID

private static final java.lang.String WHERE_ID
See Also:
Constant Field Values

WHERE_T_ID

private static final java.lang.String WHERE_T_ID
See Also:
Constant Field Values

USER_ID

private static final java.lang.String USER_ID
See Also:
Constant Field Values

CREATION_DATE

private static final java.lang.String CREATION_DATE
See Also:
Constant Field Values

LAST_USED_DATE

private static final java.lang.String LAST_USED_DATE
See Also:
Constant Field Values

AND

private static final java.lang.String AND
See Also:
Constant Field Values

SPACE

private static final java.lang.String SPACE
See Also:
Constant Field Values

SPACE_OPEN

private static final java.lang.String SPACE_OPEN
See Also:
Constant Field Values

CLOSE

private static final java.lang.String CLOSE
See Also:
Constant Field Values

LOGON_USER_KEY

private static final java.lang.String LOGON_USER_KEY
See Also:
Constant Field Values

UPDATE

private static final java.lang.String UPDATE
See Also:
Constant Field Values

SET_LAST_USED_DATE

private static final java.lang.String SET_LAST_USED_DATE
See Also:
Constant Field Values

SELECT_ID

private static final java.lang.String SELECT_ID
See Also:
Constant Field Values

WHERE_USER

private static final java.lang.String WHERE_USER
See Also:
Constant Field Values

LAST_USED

private static final java.lang.String LAST_USED
See Also:
Constant Field Values

theUser

protected User theUser
The session's User.


createDate

protected java.util.Date createDate
The date of the session


lastUsedDate

protected java.util.Date lastUsedDate
The last used date of the session


timeout_span_mins

protected int timeout_span_mins
No of minutes until time out.


timeout_span_millis

protected int timeout_span_millis
No of millis until time out.


id

protected int id
The session id


df

protected static java.text.SimpleDateFormat df
The date format used.

Constructor Detail

Session

public Session()
        throws java.sql.SQLException
/* Called to make a new session.


Session

public Session(int id)
        throws java.sql.SQLException
Get a sesssion from the RuntimeDataSource, given an id.

Method Detail

getEntityName

public java.lang.String getEntityName()
Get the entity name of this entity bean, used to identify this bean within the EntityBeanStore. And also optionally used as the key for this bean on the HttpSession.


getTheUser

public User getTheUser()
Get the session's User.


setTheUser

public void setTheUser(User theUser)
Set the session's User.


getCreateDate

public java.util.Date getCreateDate()
Get the date of the session


setCreateDate

public void setCreateDate(java.util.Date createDate)
Set the date of the session


getLastUsedDate

public java.util.Date getLastUsedDate()
Get the date of the session


setLastUsedDate

public void setLastUsedDate(java.util.Date lastUsedDate)
Set the date of the session


hasTimedOut

public boolean hasTimedOut()
Whether this Session has timed out.


getId

public int getId()
Get the session id

Specified by:
getId in interface EntityBean

setId

public void setId(int id)
Set the session id

Specified by:
setId in interface EntityBean

save

public void save()
          throws java.sql.SQLException
Save this session

Specified by:
save in interface EntityBean

delete

public void delete()
            throws java.sql.SQLException
Tear down this session

Specified by:
delete in interface EntityBean

logUserIn

public static Session logUserIn(User user,
                                javax.servlet.http.HttpServletRequest request)
                         throws java.sql.SQLException
Log a user in to the website. Put their User object on the HttpSession, create a new Session, and update the user's last login date on the Pivotal database.


doQuickUpdate

public void doQuickUpdate()
Update the last used date in the db, by hitting it only once. This to make UpdateSessionTag more efficient.


deleteExpiredSessionsForUser

public static void deleteExpiredSessionsForUser(User user)
Delete all expired Sessions for a given User.


getNumberOfActiveSessions

public static int getNumberOfActiveSessions()
Gets the number of active sessions, for all users.


getUsersWithActiveSessions

public static java.util.Iterator getUsersWithActiveSessions()
Gets an Iterator of all active User beans in the system.


getUsersWithActiveSessionsAsList

public static java.util.List getUsersWithActiveSessionsAsList()
Gets a List of all active User beans in the system.


getActiveSessionsList

public static java.util.List getActiveSessionsList()
Gets a List of all active session.