org.eclipse.jetty.server.session
Class JDBCSessionIdManager

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.eclipse.jetty.server.session.AbstractSessionIdManager
          extended by org.eclipse.jetty.server.session.JDBCSessionIdManager
All Implemented Interfaces:
SessionIdManager, LifeCycle

public class JDBCSessionIdManager
extends AbstractSessionIdManager

JDBCSessionIdManager SessionIdManager implementation that uses a database to store in-use session ids, to support distributed sessions.


Nested Class Summary
 class JDBCSessionIdManager.DatabaseAdaptor
          DatabaseAdaptor Handles differences between databases.
 
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
 
Field Summary
protected  String _blobType
           
protected  String _connectionUrl
           
protected  String _createSessionIdTable
           
protected  String _createSessionTable
           
protected  DataSource _datasource
           
protected  JDBCSessionIdManager.DatabaseAdaptor _dbAdaptor
           
protected  String _deleteId
           
protected  String _deleteOldExpiredSessions
           
protected  String _driverClassName
           
protected  String _insertId
           
protected  String _jndiName
           
protected  long _lastScavengeTime
           
protected  String _queryId
           
protected  long _scavengeIntervalMs
           
protected  String _selectExpiredSessions
           
protected  Server _server
           
protected  HashSet<String> _sessionIds
           
protected  String _sessionIdTable
           
protected  String _sessionTable
           
protected  String _sessionTableRowId
           
protected  TimerTask _task
           
protected  Timer _timer
           
 
Fields inherited from class org.eclipse.jetty.server.session.AbstractSessionIdManager
_random, _weakRandom, _workerName
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Constructor Summary
JDBCSessionIdManager(Server server)
           
JDBCSessionIdManager(Server server, Random random)
           
 
Method Summary
 void addSession(HttpSession session)
          Add a session to the list of known sessions for a given ID.
 void doStart()
          Start up the id manager.
 void doStop()
          Stop the scavenger.
 String getBlobType()
           
 String getClusterId(String nodeId)
          Get the session id without any node identifier suffix.
protected  Connection getConnection()
          Get a connection from the driver or datasource.
 String getConnectionUrl()
           
 String getDatasourceName()
           
 String getDriverClassName()
           
 String getNodeId(String clusterId, HttpServletRequest request)
          Get the session id, including this node's id as a suffix.
 long getScavengeInterval()
           
 boolean idInUse(String id)
           
 void invalidateAll(String id)
          Invalidate the session matching the id on all contexts.
 void removeSession(HttpSession session)
          Remove session from the list of known sessions for a given ID.
 void removeSession(String id)
           
 void setBlobType(String name)
           
 void setDatasourceName(String jndi)
           
 void setDriverInfo(String driverClassName, String connectionUrl)
          Configure jdbc connection information via a jdbc Driver
 void setScavengeInterval(long sec)
           
 
Methods inherited from class org.eclipse.jetty.server.session.AbstractSessionIdManager
getRandom, getWorkerName, initRandom, newSessionId, setRandom, setWorkerName
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

Field Detail

_sessionIds

protected final HashSet<String> _sessionIds

_server

protected Server _server

_driverClassName

protected String _driverClassName

_connectionUrl

protected String _connectionUrl

_datasource

protected DataSource _datasource

_jndiName

protected String _jndiName

_sessionIdTable

protected String _sessionIdTable

_sessionTable

protected String _sessionTable

_sessionTableRowId

protected String _sessionTableRowId

_timer

protected Timer _timer

_task

protected TimerTask _task

_lastScavengeTime

protected long _lastScavengeTime

_scavengeIntervalMs

protected long _scavengeIntervalMs

_blobType

protected String _blobType

_createSessionIdTable

protected String _createSessionIdTable

_createSessionTable

protected String _createSessionTable

_selectExpiredSessions

protected String _selectExpiredSessions

_deleteOldExpiredSessions

protected String _deleteOldExpiredSessions

_insertId

protected String _insertId

_deleteId

protected String _deleteId

_queryId

protected String _queryId

_dbAdaptor

protected JDBCSessionIdManager.DatabaseAdaptor _dbAdaptor
Constructor Detail

JDBCSessionIdManager

public JDBCSessionIdManager(Server server)

JDBCSessionIdManager

public JDBCSessionIdManager(Server server,
                            Random random)
Method Detail

setDriverInfo

public void setDriverInfo(String driverClassName,
                          String connectionUrl)
Configure jdbc connection information via a jdbc Driver

Parameters:
driverClassName -
connectionUrl -

getDriverClassName

public String getDriverClassName()

getConnectionUrl

public String getConnectionUrl()

setDatasourceName

public void setDatasourceName(String jndi)

getDatasourceName

public String getDatasourceName()

setBlobType

public void setBlobType(String name)

getBlobType

public String getBlobType()

setScavengeInterval

public void setScavengeInterval(long sec)

getScavengeInterval

public long getScavengeInterval()

addSession

public void addSession(HttpSession session)
Description copied from interface: SessionIdManager
Add a session to the list of known sessions for a given ID.

Parameters:
session - The session

removeSession

public void removeSession(HttpSession session)
Description copied from interface: SessionIdManager
Remove session from the list of known sessions for a given ID.


removeSession

public void removeSession(String id)

getClusterId

public String getClusterId(String nodeId)
Get the session id without any node identifier suffix.

Returns:
the cluster id
See Also:
SessionIdManager.getClusterId(java.lang.String)

getNodeId

public String getNodeId(String clusterId,
                        HttpServletRequest request)
Get the session id, including this node's id as a suffix.

Parameters:
clusterId - The ID of the session
request - The request that for the session (or null)
Returns:
The session ID qualified with the node ID.
See Also:
SessionIdManager.getNodeId(java.lang.String, javax.servlet.http.HttpServletRequest)

idInUse

public boolean idInUse(String id)
Parameters:
id - The session ID without any cluster node extension
Returns:
True if the session ID is in use by at least one context.

invalidateAll

public void invalidateAll(String id)
Invalidate the session matching the id on all contexts.

Parameters:
id - The session ID without any cluster node extension
See Also:
SessionIdManager.invalidateAll(java.lang.String)

doStart

public void doStart()
Start up the id manager. Makes necessary database tables and starts a Session scavenger thread.

Overrides:
doStart in class AbstractSessionIdManager

doStop

public void doStop()
            throws Exception
Stop the scavenger.

Overrides:
doStop in class AbstractSessionIdManager
Throws:
Exception

getConnection

protected Connection getConnection()
                            throws SQLException
Get a connection from the driver or datasource.

Returns:
the connection for the datasource
Throws:
SQLException


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.