org.locomotive.loco.store.session
Class SessionStore

java.lang.Object
  |
  +--org.locomotive.loco.store.session.SessionStore
Direct Known Subclasses:
SessionStoreJdbc

public abstract class SessionStore
extends java.lang.Object


Constructor Summary
SessionStore()
           
 
Method Summary
abstract  void associateUser(java.sql.Connection conn, User user, long sid)
          associate a user with this session, persistantly.
abstract  long createNewSession(java.sql.Connection conn, int srid, int userid, java.sql.Timestamp expire)
          Saves a new Session and returns its sid
abstract  void expire(java.sql.Connection conn, long sid, java.sql.Timestamp expireTime)
          expires this session, in the database returns false if the operation failed
abstract  LocoSessionRow getLocoSessionRow(java.sql.Connection conn, long sid)
          Returns an individual session row if it can be found.
protected abstract  java.math.BigInteger getNextSessionId(java.sql.Connection conn)
          Returns the next available id to use when saving a new session
abstract  java.util.Hashtable getSessionObjects(java.sql.Connection conn, long sid)
          Returns the objects for the individual session
abstract  void removeObjects(java.sql.Connection conn, long sid)
          Removes the objects for this session, either from the cache, if it's being used, or from the database
abstract  void resetExpiration(java.sql.Connection conn, long sid, java.sql.Timestamp expireTime)
          Advances the expiration time of the session by exp_seconds if the session is persistant, the new time will be committed to the session database
abstract  void storeObjects(java.sql.Connection conn, long sid, java.util.Hashtable objects)
          Stores the session_objects table in the database.
abstract  void storeSessionObjects(java.sql.Connection conn, java.util.Hashtable objects)
          Saves a new Session and returns its sid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionStore

public SessionStore()
Method Detail

associateUser

public abstract void associateUser(java.sql.Connection conn,
                                   User user,
                                   long sid)
                            throws FailedSessionException
associate a user with this session, persistantly. Authentication should be handled externally
Parameters:
conn - a JDBC connection with access to the Loco tables
user - the user to be associated
sid - the session id
Throws:
FailedSessionException - if there is a database storage problem

expire

public abstract void expire(java.sql.Connection conn,
                            long sid,
                            java.sql.Timestamp expireTime)
                     throws FailedSessionException
expires this session, in the database returns false if the operation failed
Parameters:
conn - a JDBC connection with access to the Loco session tables
sid - the session id
expireTime - The timestamp
Throws:
FailedSessionException - if the session cannot be marked in the database

storeObjects

public abstract void storeObjects(java.sql.Connection conn,
                                  long sid,
                                  java.util.Hashtable objects)
                           throws java.sql.SQLException
Stores the session_objects table in the database. Should be called to store the session's resources after the session has been used for a request, if caching is not being used.
Parameters:
conn - a JDBC connection with access to the Loco session tables
sid - the session id
objects - the hashtable of objects to be saved

removeObjects

public abstract void removeObjects(java.sql.Connection conn,
                                   long sid)
                            throws FailedSessionException
Removes the objects for this session, either from the cache, if it's being used, or from the database
Parameters:
conn - a JDBC connection with access to the Loco session tables
sid - the session id
Throws:
FailedSessionException - if the session cannot be marked in the database

resetExpiration

public abstract void resetExpiration(java.sql.Connection conn,
                                     long sid,
                                     java.sql.Timestamp expireTime)
                              throws FailedSessionException
Advances the expiration time of the session by exp_seconds if the session is persistant, the new time will be committed to the session database
Parameters:
conn - a JDBC connection with access to the Loco session tables
sid - the session id
expireTime - The timestamp
Throws:
FailedSessionException - if there is a database error

getLocoSessionRow

public abstract LocoSessionRow getLocoSessionRow(java.sql.Connection conn,
                                                 long sid)
                                          throws FailedSessionException
Returns an individual session row if it can be found. Returns an object because there are multiple return values The LocoSessionRow is a prime candidate for a pool to reduce object creation/destruction
Parameters:
conn - a JDBC connection with access to the Loco session tables
sid - the session id
Throws:
FailedSessionException - if there is a database error or the session cannot be found

getSessionObjects

public abstract java.util.Hashtable getSessionObjects(java.sql.Connection conn,
                                                      long sid)
                                               throws FailedSessionException
Returns the objects for the individual session
Parameters:
conn - a JDBC connection with access to the Loco session tables
sid - the session id
Throws:
FailedSessionException - if there is a database error or the session cannot be found

createNewSession

public abstract long createNewSession(java.sql.Connection conn,
                                      int srid,
                                      int userid,
                                      java.sql.Timestamp expire)
                               throws FailedSessionException
Saves a new Session and returns its sid
Parameters:
conn - a JDBC connection with access to the Loco session tables
srid - the random number for cookie checks
userid - the user
expire - the timestamp
Throws:
FailedSessionException - if there is a database error or the session cannot be found

storeSessionObjects

public abstract void storeSessionObjects(java.sql.Connection conn,
                                         java.util.Hashtable objects)
Saves a new Session and returns its sid
Parameters:
conn - a JDBC connection with access to the Loco session tables
sid - the session id
objects - the hashtable of objects to be saved
Throws:
FailedSessionException - if there is a database error or the session cannot be found

getNextSessionId

protected abstract java.math.BigInteger getNextSessionId(java.sql.Connection conn)
                                                  throws IdException
Returns the next available id to use when saving a new session
Parameters:
conn - a JDBC connection with access to the Loco id table
Throws:
IdException - if the id could not be generated