org.abstracthorizon.danube.http.session
Class SimpleSessionManager

java.lang.Object
  extended by org.abstracthorizon.danube.http.session.SimpleCookieSessionManager
      extended by org.abstracthorizon.danube.http.session.SimpleSessionManager
All Implemented Interfaces:
HTTPSessionManager, SessionManager

public class SimpleSessionManager
extends SimpleCookieSessionManager

Simple session manager implementation that checks for expired sessions on invocation of HTTPSessionManager methods. If method is invoked sooner then minScanInterval then scan won't happen.

Author:
Daniel Sendula

Field Summary
static int DEFAULT_MIN_SCAN_INTERVAL
          Default minimum interval between scans for expired sessions
static int DEFAULT_SESSION_TIMEOUT
          Default session timeout as 30 minutes
protected  long lastScan
          When was last scan performed
protected  int minScanInterval
          Minimum interval between two scans for expired sessions
protected  int sessionTimeout
          Current session timeout
 
Fields inherited from class org.abstracthorizon.danube.http.session.SimpleCookieSessionManager
random, SESSION_ATTRIBUTE, SESSION_COOKIE_NAME, sessionCookieName, sessions
 
Constructor Summary
SimpleSessionManager()
           
 
Method Summary
protected  void checkForExpiredSessions()
          Checks if there are expired sessions.
 Object findSession(HTTPConnection connection, boolean create)
          Finds a session for supplied connection
 Object findSession(Object sessionId, boolean create)
          Searches for the session using givne session id
 int getMinScanInterval()
          Returns minimum interval between scans for expired sessions
 int getSessionTimeout()
          Returns session timeout
 void removeSession(HTTPConnection connection)
          Removes session from connection
 void removeSession(Object session)
          This object removes existing session
 String rewriteURL(HTTPConnection connection, String url)
          Rewrites URL for given connection
protected  void scanForExpiredSessions()
          Scans all defined sessions for expired ones
 void setMinScanInterval(int minScanInterval)
          Sets minimum interval between scans for expired sessions
 void setSessionTimeout(int sessionTimeout)
          Sets session timeout
 
Methods inherited from class org.abstracthorizon.danube.http.session.SimpleCookieSessionManager
createSession, createSessionId, getSessionCookieName, setSessionCookieName, validateSessionId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SESSION_TIMEOUT

public static final int DEFAULT_SESSION_TIMEOUT
Default session timeout as 30 minutes

See Also:
Constant Field Values

DEFAULT_MIN_SCAN_INTERVAL

public static final int DEFAULT_MIN_SCAN_INTERVAL
Default minimum interval between scans for expired sessions

See Also:
Constant Field Values

sessionTimeout

protected int sessionTimeout
Current session timeout


lastScan

protected long lastScan
When was last scan performed


minScanInterval

protected int minScanInterval
Minimum interval between two scans for expired sessions

Constructor Detail

SimpleSessionManager

public SimpleSessionManager()
Method Detail

findSession

public Object findSession(HTTPConnection connection,
                          boolean create)
Finds a session for supplied connection

Specified by:
findSession in interface HTTPSessionManager
Overrides:
findSession in class SimpleCookieSessionManager
Parameters:
connection - connection
create - flag defining should session be created it doesn't exist already
Returns:
existing session object, new session if existing session is not there and create param is set to true or null otherwise.

findSession

public Object findSession(Object sessionId,
                          boolean create)
Searches for the session using givne session id

Specified by:
findSession in interface SessionManager
Overrides:
findSession in class SimpleCookieSessionManager
Parameters:
sessionId - session id object
create - flag defining should session be created it doesn't exist already
Returns:
existing session object, new session if existing session is not there and create param is set to true or null otherwise.

removeSession

public void removeSession(HTTPConnection connection)
Removes session from connection

Specified by:
removeSession in interface HTTPSessionManager
Overrides:
removeSession in class SimpleCookieSessionManager
Parameters:
connection - connection

removeSession

public void removeSession(Object session)
This object removes existing session

Specified by:
removeSession in interface SessionManager
Overrides:
removeSession in class SimpleCookieSessionManager
Parameters:
session - session to be removed

rewriteURL

public String rewriteURL(HTTPConnection connection,
                         String url)
Rewrites URL for given connection

Specified by:
rewriteURL in interface HTTPSessionManager
Overrides:
rewriteURL in class SimpleCookieSessionManager
Parameters:
url - URL to be rewritten
connection - http connection object
Returns:
updated url

checkForExpiredSessions

protected void checkForExpiredSessions()
Checks if there are expired sessions. This method won't run if it was invoked in less then minScanInterval time.


scanForExpiredSessions

protected void scanForExpiredSessions()
Scans all defined sessions for expired ones


getSessionTimeout

public int getSessionTimeout()
Returns session timeout

Returns:
session timeout

setSessionTimeout

public void setSessionTimeout(int sessionTimeout)
Sets session timeout

Parameters:
sessionTimeout - session timeout

getMinScanInterval

public int getMinScanInterval()
Returns minimum interval between scans for expired sessions

Returns:
minimum interval between scans for expired sessions

setMinScanInterval

public void setMinScanInterval(int minScanInterval)
Sets minimum interval between scans for expired sessions

Parameters:
minScanInterval - minimum interval between scans for expired sessions


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.