Package 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
,org.eclipse.jetty.util.component.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 Modifier and Type Class Description static class
JDBCSessionIdManager.DatabaseAdaptor
DatabaseAdaptor Handles differences between databases.protected class
JDBCSessionIdManager.Scavenger
Scavengerstatic class
JDBCSessionIdManager.SessionIdTableSchema
SessionIdTableSchemastatic class
JDBCSessionIdManager.SessionTableSchema
SessionTableSchema
-
Field Summary
-
Fields inherited from class org.eclipse.jetty.server.session.AbstractSessionIdManager
_random, _reseed, _weakRandom, _workerAttr, _workerName
-
-
Constructor Summary
Constructors Constructor Description JDBCSessionIdManager(Server server)
JDBCSessionIdManager(Server server, Random random)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addSession(String id)
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()
Deprecated.see DbAdaptor.getBlobTypeprotected Connection
getConnection()
Get a connection from the driver or datasource.String
getConnectionUrl()
DataSource
getDataSource()
String
getDatasourceName()
JDBCSessionIdManager.DatabaseAdaptor
getDbAdaptor()
int
getDeleteBlockSize()
String
getDriverClassName()
String
getLongType()
Deprecated.see DbAdaptor.getLogTypelong
getScavengeInterval()
JDBCSessionIdManager.SessionIdTableSchema
getSessionIdTableSchema()
JDBCSessionIdManager.SessionTableSchema
getSessionTableSchema()
boolean
idInUse(String id)
void
invalidateAll(String id)
Invalidate the session matching the id on all contexts.void
removeSession(String id)
void
removeSession(javax.servlet.http.HttpSession session)
Remove session from the list of known sessions for a given ID.void
renewSessionId(String oldClusterId, String oldNodeId, javax.servlet.http.HttpServletRequest request)
Change the existing session id.void
setBlobType(String name)
Deprecated.see DbAdaptor.setBlobTypevoid
setDatasource(DataSource ds)
void
setDatasourceName(String jndi)
void
setDbAdaptor(JDBCSessionIdManager.DatabaseAdaptor dbAdaptor)
void
setDeleteBlockSize(int bsize)
void
setDriverInfo(String driverClassName, String connectionUrl)
Configure jdbc connection information via a jdbc Drivervoid
setDriverInfo(Driver driverClass, String connectionUrl)
Configure jdbc connection information via a jdbc Drivervoid
setLongType(String longType)
Deprecated.see DbAdaptor.setLongTypevoid
setScavengeInterval(long sec)
void
setSessionIdTableSchema(JDBCSessionIdManager.SessionIdTableSchema sessionIdTableSchema)
void
setSessionTableSchema(JDBCSessionIdManager.SessionTableSchema sessionTableSchema)
-
Methods inherited from class org.eclipse.jetty.server.session.AbstractSessionIdManager
getClusterId, getNodeId, getRandom, getReseed, getWorkerName, initRandom, newSessionId, newSessionId, setRandom, setReseed, setWorkerName
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
-
-
-
-
Field Detail
-
MAX_INTERVAL_NOT_SET
public static final int MAX_INTERVAL_NOT_SET
- See Also:
- Constant Field Values
-
_server
protected Server _server
-
_driver
protected Driver _driver
-
_driverClassName
protected String _driverClassName
-
_connectionUrl
protected String _connectionUrl
-
_datasource
protected DataSource _datasource
-
_jndiName
protected String _jndiName
-
_deleteBlockSize
protected int _deleteBlockSize
-
_task
protected org.eclipse.jetty.util.thread.Scheduler.Task _task
-
_scheduler
protected org.eclipse.jetty.util.thread.Scheduler _scheduler
-
_scavenger
protected JDBCSessionIdManager.Scavenger _scavenger
-
_ownScheduler
protected boolean _ownScheduler
-
_lastScavengeTime
protected long _lastScavengeTime
-
_scavengeIntervalMs
protected long _scavengeIntervalMs
-
_createSessionIdTable
protected String _createSessionIdTable
-
_createSessionTable
protected String _createSessionTable
-
_selectBoundedExpiredSessions
protected String _selectBoundedExpiredSessions
-
_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
-
_sessionIdTableSchema
protected JDBCSessionIdManager.SessionIdTableSchema _sessionIdTableSchema
-
_sessionTableSchema
protected JDBCSessionIdManager.SessionTableSchema _sessionTableSchema
-
-
Method Detail
-
setDriverInfo
public void setDriverInfo(String driverClassName, String connectionUrl)
Configure jdbc connection information via a jdbc Driver- Parameters:
driverClassName
- the driver classnameconnectionUrl
- the driver connection url
-
setDriverInfo
public void setDriverInfo(Driver driverClass, String connectionUrl)
Configure jdbc connection information via a jdbc Driver- Parameters:
driverClass
- the driver classconnectionUrl
- the driver connection url
-
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
@Deprecated public void setBlobType(String name)
Deprecated.see DbAdaptor.setBlobType- Parameters:
name
- the name of the blob
-
getDbAdaptor
public JDBCSessionIdManager.DatabaseAdaptor getDbAdaptor()
-
setDbAdaptor
public void setDbAdaptor(JDBCSessionIdManager.DatabaseAdaptor dbAdaptor)
-
getBlobType
@Deprecated public String getBlobType()
Deprecated.see DbAdaptor.getBlobType- Returns:
- the blob type
-
getLongType
@Deprecated public String getLongType()
Deprecated.see DbAdaptor.getLogType- Returns:
- the long type
-
setLongType
@Deprecated public void setLongType(String longType)
Deprecated.see DbAdaptor.setLongType- Parameters:
longType
- the long type
-
getSessionIdTableSchema
public JDBCSessionIdManager.SessionIdTableSchema getSessionIdTableSchema()
-
setSessionIdTableSchema
public void setSessionIdTableSchema(JDBCSessionIdManager.SessionIdTableSchema sessionIdTableSchema)
-
getSessionTableSchema
public JDBCSessionIdManager.SessionTableSchema getSessionTableSchema()
-
setSessionTableSchema
public void setSessionTableSchema(JDBCSessionIdManager.SessionTableSchema sessionTableSchema)
-
setDeleteBlockSize
public void setDeleteBlockSize(int bsize)
-
getDeleteBlockSize
public int getDeleteBlockSize()
-
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
-
addSession
public void addSession(String id)
-
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.- Parameters:
session
- the session to remove
-
removeSession
public void removeSession(String id)
-
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)
-
renewSessionId
public void renewSessionId(String oldClusterId, String oldNodeId, javax.servlet.http.HttpServletRequest request)
Description copied from interface:SessionIdManager
Change the existing session id.- Specified by:
renewSessionId
in interfaceSessionIdManager
- Specified by:
renewSessionId
in classAbstractSessionIdManager
- Parameters:
oldClusterId
- the old cluster idoldNodeId
- the old node idrequest
- the request containing the session
-
doStart
public void doStart() throws Exception
Start up the id manager. Makes necessary database tables and starts a Session scavenger thread.- Overrides:
doStart
in classAbstractSessionIdManager
- Throws:
Exception
-
doStop
public void doStop() throws Exception
Stop the scavenger.- Overrides:
doStop
in classAbstractSessionIdManager
- Throws:
Exception
-
getConnection
protected Connection getConnection() throws SQLException
Get a connection from the driver or datasource.- Returns:
- the connection for the datasource
- Throws:
SQLException
- if unable to get the connection
-
-