org.eclipse.jetty.server.session

## Class JDBCSessionIdManager

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.server.session.AbstractSessionIdManager
    - - 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

Nested Classes
`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

Fields
`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` `_deleteSession`
`protected Driver` `_driver`
`protected String` `_driverClassName`
`protected String` `_insertId`
`protected String` `_insertSession`
`protected String` `_jndiName`
`protected long` `_lastScavengeTime`
`protected String` `_longType`
`protected String` `_queryId`
`protected long` `_scavengeIntervalMs`
`protected String` `_selectBoundedExpiredSessions`
`protected Server` `_server`
`protected HashSet<String>` `_sessionIds`
`protected String` `_sessionIdTable`
`protected String` `_sessionTable`
`protected String` `_sessionTableRowId`
`protected TimerTask` `_task`
`protected Timer` `_timer`
`protected String` `_updateSession`
`protected String` `_updateSessionAccessTime`
`protected String` `_updateSessionNode`

### Fields inherited from class org.eclipse.jetty.server.session.AbstractSessionIdManager

`_random, _reseed, _weakRandom, _workerName`

### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

`_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

### Constructor Summary

Constructors
Constructor and Description
`JDBCSessionIdManager(Server server)`
`JDBCSessionIdManager(Server server, Random random)`

### Method Summary

Methods
`void` `addSession(javax.servlet.http.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()`
`DataSource` `getDataSource()`
`String` `getDatasourceName()`
`String` `getDriverClassName()`
`String` `getLongType()`
`String` `getNodeId(String clusterId, javax.servlet.http.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(javax.servlet.http.HttpSession session)` Remove session from the list of known sessions for a given ID.
`void` `removeSession(String id)`
`void` `setBlobType(String name)`
`void` `setDatasource(DataSource ds)`
`void` `setDatasourceName(String jndi)`
`void` `setDriverInfo(Driver driverClass, String connectionUrl)` Configure jdbc connection information via a jdbc Driver
`void` `setDriverInfo(String driverClassName, String connectionUrl)` Configure jdbc connection information via a jdbc Driver
`void` `setLongType(String longType)`
`void` `setScavengeInterval(long sec)`

### Methods inherited from class org.eclipse.jetty.server.session.AbstractSessionIdManager

`getRandom, getReseed, getWorkerName, initRandom, newSessionId, setRandom, setReseed, 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

#### _driver

    protected Driver _driver

#### _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

#### _longType

    protected String _longType

#### _createSessionIdTable

    protected String _createSessionIdTable

#### _createSessionTable

    protected String _createSessionTable

#### _selectBoundedExpiredSessions

    protected String _selectBoundedExpiredSessions

#### _deleteOldExpiredSessions

    protected String _deleteOldExpiredSessions

#### _insertId

    protected String _insertId

#### _deleteId

    protected String _deleteId

#### _queryId

    protected String _queryId

#### _insertSession

    protected String _insertSession

#### _deleteSession

    protected String _deleteSession

#### _updateSession

    protected String _updateSession

#### _updateSessionNode

    protected String _updateSessionNode

#### _updateSessionAccessTime

    protected String _updateSessionAccessTime

#### _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` -

#### setDriverInfo

    public void setDriverInfo(Driver driverClass,
                     String connectionUrl)

Configure jdbc connection information via a jdbc Driver

Parameters:
  `driverClass` -
  `connectionUrl` -

#### setDatasource

    public void setDatasource(DataSource ds)

#### getDataSource

    public DataSource getDataSource()

#### 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()

#### getLongType

    public String getLongType()

#### setLongType

    public void setLongType(String longType)

#### setScavengeInterval

    public void setScavengeInterval(long sec)

#### getScavengeInterval

    public long getScavengeInterval()

#### addSession

    public void addSession(javax.servlet.http.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(javax.servlet.http.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,
                   javax.servlet.http.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()
                 throws Exception

Start up the id manager. Makes necessary database tables and starts a Session scavenger thread.

Overrides:
  `doStart` in class `AbstractSessionIdManager`
Throws:
  `Exception`

#### 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`