Top Description Inners Fields Constructors Methods
org.eclipse.jetty.session

public Class JDBCSessionDataStore

extends ObjectStreamSessionDataStore
Class Inheritance
Annotations
@ManagedObject
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .InputStream, .ObjectInputStream, .ObjectOutputStream, java.sql.Connection, .DatabaseMetaData, .PreparedStatement, .ResultSet, .SQLException, .Statement, java.util.HashSet, .Set, org.eclipse.jetty.util.StringUtil, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.slf4j.Logger, .LoggerFactory

JDBCSessionDataStore Session data stored in database

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
protected DatabaseAdaptor
protected boolean
protected boolean
protected JDBCSessionDataStore.SessionTableSchema
private static final ByteArrayInputStream
private static final Logger
public static final String
NULL_CONTEXT_PATH

Used for Oracle and other databases where "" is treated as NULL

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
delete(String
identity of session to delete
id
)

Implements org.eclipse.jetty.session.SessionDataMap.delete.

Delete session data

public Set<String>
doCheckExpired(Set<String>
the ids of sessions the SessionCache thinks has expired
candidates
,
long
the time at which to check for expiry
time
)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doCheckExpired.

Implemented by subclasses to resolve which sessions in this context that are being managed by this node that should be expired.

public void
doCleanOrphans(long
the upper limit of the expiry time to check in msec
time
)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doCleanOrphans.

Implemented by subclasses to delete sessions for other contexts that expired at or before the timeLimit.

public boolean
doExists(String
the session id to check
id
)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doExists.

Check if a session for the given id exists.

public Set<String>
doGetExpired(long
the upper limit of expiry times to check. Sessions expired at or before this timestamp will match.
timeLimit
)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doGetExpired.

Implemented by subclasses to find sessions for this context in the store that expired at or before the time limit and thus not being actively managed by any node.

protected void
public SessionData
doLoad(String
the id of the session to load
id
)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doLoad.

Load the session from persistent store.

protected void
doStart()

Overrides org.eclipse.jetty.session.AbstractSessionDataStore.doStart.

Starts the managed lifecycle beans in the order they were added.

protected void
doStop()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

public void
doStore(String
identity of session to store
id
,
SessionData
info of the session
data
,
long
time of previous save or 0 if never saved
lastSaveTime
)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doStore.

Store the session data persistently.

protected void
public void
public boolean
isPassivating()

Implements org.eclipse.jetty.session.SessionDataStore.isPassivating.

True if this type of datastore will passivate session objects

public void
public void
Inherited from org.eclipse.jetty.session.ObjectStreamSessionDataStore:
deserializeAttributesnewObjectInputStreamnewObjectOutputStreamserializeAttributes

Field Detail

_dbAdaptorback to summary
protected DatabaseAdaptor _dbAdaptor
_initializedback to summary
protected boolean _initialized
_schemaProvidedback to summary
protected boolean _schemaProvided
_sessionTableSchemaback to summary
protected JDBCSessionDataStore.SessionTableSchema _sessionTableSchema
EMPTYback to summary
private static final ByteArrayInputStream EMPTY
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.session.AbstractSessionDataStore.LOG.

NULL_CONTEXT_PATHback to summary
public static final String NULL_CONTEXT_PATH

Used for Oracle and other databases where "" is treated as NULL

Constructor Detail

JDBCSessionDataStoreback to summary
public JDBCSessionDataStore()

Method Detail

deleteback to summary
public boolean delete(String id) throws Exception

Implements org.eclipse.jetty.session.SessionDataMap.delete.

Doc from org.eclipse.jetty.session.SessionDataMap.delete.

Delete session data

Parameters
id:String

identity of session to delete

Returns:boolean

true if the session was deleted

Annotations
@Override
Exceptions
Exception:
if unable to delete session data
doCheckExpiredback to summary
public Set<String> doCheckExpired(Set<String> candidates, long time)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doCheckExpired.

Doc from org.eclipse.jetty.session.AbstractSessionDataStore.doCheckExpired.

Implemented by subclasses to resolve which sessions in this context that are being managed by this node that should be expired.

Parameters
candidates:Set<String>

the ids of sessions the SessionCache thinks has expired

time:long

the time at which to check for expiry

Returns:Set<String>

the reconciled set of session ids that have been checked in the store

Annotations
@Override
doCleanOrphansback to summary
public void doCleanOrphans(long time)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doCleanOrphans.

Doc from org.eclipse.jetty.session.AbstractSessionDataStore.doCleanOrphans.

Implemented by subclasses to delete sessions for other contexts that expired at or before the timeLimit. These are 'orphaned' sessions that are no longer being actively managed by any node. These are explicitly sessions that do NOT belong to this context (other mechanisms such as doGetExpired take care of those). As they don't belong to this context, they cannot be loaded by us. This is called only periodically to avoid placing excessive load on the store.

Parameters
time:long

the upper limit of the expiry time to check in msec

Annotations
@Override
doExistsback to summary
public boolean doExists(String id) throws Exception

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doExists.

Doc from org.eclipse.jetty.session.AbstractSessionDataStore.doExists.

Check if a session for the given id exists.

Parameters
id:String

the session id to check

Returns:boolean

true if the session exists in the persistent store, false otherwise

Annotations
@Override
doGetExpiredback to summary
public Set<String> doGetExpired(long timeLimit)

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doGetExpired.

Doc from org.eclipse.jetty.session.AbstractSessionDataStore.doGetExpired.

Implemented by subclasses to find sessions for this context in the store that expired at or before the time limit and thus not being actively managed by any node. This method is only called periodically (the period is configurable) to avoid putting too much load on the store.

Parameters
timeLimit:long

the upper limit of expiry times to check. Sessions expired at or before this timestamp will match.

Returns:Set<String>

the empty set if there are no sessions expired as at the time, or otherwise a set of session ids.

Annotations
@Override
doInsertback to summary
protected void doInsert(String id, SessionData data) throws Exception
doLoadback to summary
public SessionData doLoad(String id) throws Exception

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doLoad.

Doc from org.eclipse.jetty.session.AbstractSessionDataStore.doLoad.

Load the session from persistent store.

Parameters
id:String

the id of the session to load

Returns:SessionData

the re-inflated session

Annotations
@Override
Exceptions
Exception:
if unable to load the session
doStartback to summary
protected void doStart() throws Exception

Overrides org.eclipse.jetty.session.AbstractSessionDataStore.doStart.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStart.

If there was a problem starting. Will cause a transition to FAILED state

doStopback to summary
protected void doStop() throws Exception

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStop.

If there was a problem stopping. Will cause a transition to FAILED state

doStoreback to summary
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception

Implements abstract org.eclipse.jetty.session.AbstractSessionDataStore.doStore.

Doc from org.eclipse.jetty.session.AbstractSessionDataStore.doStore.

Store the session data persistently.

Parameters
id:String

identity of session to store

data:SessionData

info of the session

lastSaveTime:long

time of previous save or 0 if never saved

Annotations
@Override
Exceptions
Exception:
if unable to store data
doUpdateback to summary
protected void doUpdate(String id, SessionData data) throws Exception
initializeback to summary
public void initialize() throws Exception
isPassivatingback to summary
public boolean isPassivating()

Implements org.eclipse.jetty.session.SessionDataStore.isPassivating.

Doc from org.eclipse.jetty.session.SessionDataStore.isPassivating.

True if this type of datastore will passivate session objects

Returns:boolean

true if this store can passivate sessions, false otherwise

Annotations
@Override
@ManagedAttribute:does this store serialize sessions
readonly:true
setDatabaseAdaptorback to summary
public void setDatabaseAdaptor(DatabaseAdaptor dbAdaptor)
setSessionTableSchemaback to summary
public void setSessionTableSchema(JDBCSessionDataStore.SessionTableSchema schema)
org.eclipse.jetty.session back to summary

public Class JDBCSessionDataStore.SessionTableSchema

extends Object
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.session.JDBCSessionDataStore.SessionTableSchema

SessionTableSchema

Field Summary

Modifier and TypeField and Description
protected String
protected String
protected String
protected String
protected String
protected DatabaseAdaptor
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
public static final String
public static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public String
public String
public String
public PreparedStatement
public PreparedStatement
getCleanOrphansStatement(Connection connection, long timeLimit)

public String
public String
public String
public String
public String
public String
public PreparedStatement
public PreparedStatement
getExpiredSessionsStatement(Connection connection, String canonicalContextPath, String vhost, long expiry)

public String
public String
public String
public String
public String
public String
public PreparedStatement
getLoadStatement(Connection connection, String id, SessionContext contextId)

public String
public String
public PreparedStatement
getMyExpiredSessionsStatement(Connection connection, SessionContext sessionContext, long expiry)

public String
private String
public String
public PreparedStatement
public PreparedStatement
public String
public void
prepareTables()

Set up the tables in the database

public void
setAccessTimeColumn(String accessTimeColumn)

public void
setCatalogName(String catalogName)

public void
setContextPathColumn(String contextPathColumn)

public void
setCookieTimeColumn(String cookieTimeColumn)

public void
setCreateTimeColumn(String createTimeColumn)

protected void
public void
setExpiryTimeColumn(String expiryTimeColumn)

public void
setIdColumn(String idColumn)

public void
setLastAccessTimeColumn(String lastAccessTimeColumn)

public void
setLastNodeColumn(String lastNodeColumn)

public void
setLastSavedTimeColumn(String lastSavedTimeColumn)

public void
setMapColumn(String mapColumn)

public void
setMaxIntervalColumn(String maxIntervalColumn)

public void
setSchemaName(String schemaName)

public void
setTableName(String tableName)

public void
setVirtualHostColumn(String virtualHostColumn)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_accessTimeColumnback to summary
protected String _accessTimeColumn
_catalogNameback to summary
protected String _catalogName
_contextPathColumnback to summary
protected String _contextPathColumn
_cookieTimeColumnback to summary
protected String _cookieTimeColumn
_createTimeColumnback to summary
protected String _createTimeColumn
_dbAdaptorback to summary
protected DatabaseAdaptor _dbAdaptor
_expiryTimeColumnback to summary
protected String _expiryTimeColumn
_idColumnback to summary
protected String _idColumn
_lastAccessTimeColumnback to summary
protected String _lastAccessTimeColumn
_lastNodeColumnback to summary
protected String _lastNodeColumn
_lastSavedTimeColumnback to summary
protected String _lastSavedTimeColumn
_mapColumnback to summary
protected String _mapColumn
_maxIntervalColumnback to summary
protected String _maxIntervalColumn
_schemaNameback to summary
protected String _schemaName
_tableNameback to summary
protected String _tableName
_virtualHostColumnback to summary
protected String _virtualHostColumn
INFERREDback to summary
public static final String INFERRED
MAX_INTERVAL_NOT_SETback to summary
public static final int MAX_INTERVAL_NOT_SET

Constructor Detail

SessionTableSchemaback to summary
public SessionTableSchema()

Method Detail

checkNotNullback to summary
private void checkNotNull(String s)
getAccessTimeColumnback to summary
public String getAccessTimeColumn()
getAlterTableForMaxIntervalAsStringback to summary
public String getAlterTableForMaxIntervalAsString()
getCatalogNameback to summary
public String getCatalogName()
getCheckSessionExistsStatementback to summary
public PreparedStatement getCheckSessionExistsStatement(Connection connection, SessionContext context) throws SQLException
getCleanOrphansStatementback to summary
public PreparedStatement getCleanOrphansStatement(Connection connection, long timeLimit) throws Exception
getContextPathColumnback to summary
public String getContextPathColumn()
getCookieTimeColumnback to summary
public String getCookieTimeColumn()
getCreateIndexOverExpiryStatementAsStringback to summary
public String getCreateIndexOverExpiryStatementAsString(String indexName)
getCreateIndexOverSessionStatementAsStringback to summary
public String getCreateIndexOverSessionStatementAsString(String indexName)
getCreateStatementAsStringback to summary
public String getCreateStatementAsString()
getCreateTimeColumnback to summary
public String getCreateTimeColumn()
getDeleteStatementback to summary
public PreparedStatement getDeleteStatement(Connection connection, String id, SessionContext contextId) throws Exception
getExpiredSessionsStatementback to summary
public PreparedStatement getExpiredSessionsStatement(Connection connection, String canonicalContextPath, String vhost, long expiry) throws SQLException
getExpiryTimeColumnback to summary
public String getExpiryTimeColumn()
getIdColumnback to summary
public String getIdColumn()
getInsertSessionStatementAsStringback to summary
public String getInsertSessionStatementAsString()
getLastAccessTimeColumnback to summary
public String getLastAccessTimeColumn()
getLastNodeColumnback to summary
public String getLastNodeColumn()
getLastSavedTimeColumnback to summary
public String getLastSavedTimeColumn()
getLoadStatementback to summary
public PreparedStatement getLoadStatement(Connection connection, String id, SessionContext contextId) throws SQLException
getMapColumnback to summary
public String getMapColumn()
getMaxIntervalColumnback to summary
public String getMaxIntervalColumn()
getMyExpiredSessionsStatementback to summary
public PreparedStatement getMyExpiredSessionsStatement(Connection connection, SessionContext sessionContext, long expiry) throws SQLException
getSchemaNameback to summary
public String getSchemaName()
getSchemaTableNameback to summary
private String getSchemaTableName()
getTableNameback to summary
public String getTableName()
getUpdateSessionStatementback to summary
public PreparedStatement getUpdateSessionStatement(Connection connection, String id, SessionContext context) throws SQLException
getUpdateStatementback to summary
public PreparedStatement getUpdateStatement(Connection connection, String id, SessionContext contextId) throws SQLException
getVirtualHostColumnback to summary
public String getVirtualHostColumn()
prepareTablesback to summary
public void prepareTables() throws SQLException

Set up the tables in the database

Exceptions
SQLException:
if unable to prepare tables
setAccessTimeColumnback to summary
public void setAccessTimeColumn(String accessTimeColumn)
setCatalogNameback to summary
public void setCatalogName(String catalogName)
setContextPathColumnback to summary
public void setContextPathColumn(String contextPathColumn)
setCookieTimeColumnback to summary
public void setCookieTimeColumn(String cookieTimeColumn)
setCreateTimeColumnback to summary
public void setCreateTimeColumn(String createTimeColumn)
setDatabaseAdaptorback to summary
protected void setDatabaseAdaptor(DatabaseAdaptor dbadaptor)
setExpiryTimeColumnback to summary
public void setExpiryTimeColumn(String expiryTimeColumn)
setIdColumnback to summary
public void setIdColumn(String idColumn)
setLastAccessTimeColumnback to summary
public void setLastAccessTimeColumn(String lastAccessTimeColumn)
setLastNodeColumnback to summary
public void setLastNodeColumn(String lastNodeColumn)
setLastSavedTimeColumnback to summary
public void setLastSavedTimeColumn(String lastSavedTimeColumn)
setMapColumnback to summary
public void setMapColumn(String mapColumn)
setMaxIntervalColumnback to summary
public void setMaxIntervalColumn(String maxIntervalColumn)
setSchemaNameback to summary
public void setSchemaName(String schemaName)
setTableNameback to summary
public void setTableName(String tableName)
setVirtualHostColumnback to summary
public void setVirtualHostColumn(String virtualHostColumn)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override