Class DataSourceStore
java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.session.StoreBase
org.apache.catalina.session.DataSourceStore
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
Lifecycle.SingleUse -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataSourceDataSource to useprotected Stringname of the JNDI resourceprotected StringColumn to use for /Engine/Host/Context nameprotected StringData column to use.protected StringId column to use.protected StringLast Accessed column to use.protected StringMax Inactive column to use.protected StringTable to use.protected StringIs Validcolumn to use.protected static final StringName to register for this Store, used for logging.Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove all Sessions from this Store.protected voidclose(Connection dbConnection) Close the specified database connection.String[]Get only those keys of sessions, that are saved in the Store and are to be expired.protected ConnectionCheck the connection associated with this store, if it'snullor closed try to reopen it.booleangetName()intgetSize()String[]keys()Load and return the Session associated with the specified session identifier from this Store, without removing it.protected Connectionopen()Open (if necessary) and return a database connection for use by this Store.protected voidrelease(Connection conn) Release the connection, if it is associated with a connection pool.voidRemove the Session with the specified session identifier from this Store, if present.voidSave the specified Session into this Store.voidsetDataSourceName(String dataSourceName) Set the JNDI name of a DataSource-factory to use for db accessvoidsetLocalDataSource(boolean localDataSource) Set totrueto cause the datasource to be looked up in the webapp JNDI Context.voidsetSessionAppCol(String sessionAppCol) Set the App column for the table.voidsetSessionDataCol(String sessionDataCol) Set the Data column for the tablevoidsetSessionIdCol(String sessionIdCol) Set the Id column for the table.voidsetSessionLastAccessedCol(String sessionLastAccessedCol) Set theLast Accessedcolumn for the tablevoidsetSessionMaxInactiveCol(String sessionMaxInactiveCol) Set theMax Inactivecolumn for the tablevoidsetSessionTable(String sessionTable) Set the table for this Store.voidsetSessionValidCol(String sessionValidCol) Set theIs Validcolumn for the tableMethods inherited from class org.apache.catalina.session.StoreBase
addPropertyChangeListener, destroyInternal, getManager, getObjectInputStream, initInternal, processExpires, removePropertyChangeListener, setManager, startInternal, stopInternal, toStringMethods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
-
Field Details
-
storeName
Name to register for this Store, used for logging.- See Also:
-
dataSourceName
name of the JNDI resource -
dataSource
DataSource to use -
sessionTable
Table to use. -
sessionAppCol
Column to use for /Engine/Host/Context name -
sessionIdCol
Id column to use. -
sessionDataCol
Data column to use. -
sessionValidCol
Is Validcolumn to use. -
sessionMaxInactiveCol
Max Inactive column to use. -
sessionLastAccessedCol
Last Accessed column to use.
-
-
Constructor Details
-
DataSourceStore
public DataSourceStore()
-
-
Method Details
-
getName
- Returns:
- the name for this instance (built from container name)
-
getStoreName
- Overrides:
getStoreNamein classStoreBase- Returns:
- the name for this Store, used for logging.
-
setSessionTable
Set the table for this Store.- Parameters:
sessionTable- The new table
-
getSessionTable
- Returns:
- the table for this Store.
-
setSessionAppCol
Set the App column for the table.- Parameters:
sessionAppCol- the column name
-
getSessionAppCol
- Returns:
- the web application name column for the table.
-
setSessionIdCol
Set the Id column for the table.- Parameters:
sessionIdCol- the column name
-
getSessionIdCol
- Returns:
- the Id column for the table.
-
setSessionDataCol
Set the Data column for the table- Parameters:
sessionDataCol- the column name
-
getSessionDataCol
- Returns:
- the data column for the table
-
setSessionValidCol
Set theIs Validcolumn for the table- Parameters:
sessionValidCol- The column name
-
getSessionValidCol
- Returns:
- the
Is Validcolumn
-
setSessionMaxInactiveCol
Set theMax Inactivecolumn for the table- Parameters:
sessionMaxInactiveCol- The column name
-
getSessionMaxInactiveCol
- Returns:
- the
Max Inactivecolumn
-
setSessionLastAccessedCol
Set theLast Accessedcolumn for the table- Parameters:
sessionLastAccessedCol- The column name
-
getSessionLastAccessedCol
- Returns:
- the
Last Accessedcolumn
-
setDataSourceName
Set the JNDI name of a DataSource-factory to use for db access- Parameters:
dataSourceName- The JNDI name of the DataSource-factory
-
getDataSourceName
- Returns:
- the name of the JNDI DataSource-factory
-
getLocalDataSource
public boolean getLocalDataSource()- Returns:
- if the datasource will be looked up in the webapp JNDI Context.
-
setLocalDataSource
public void setLocalDataSource(boolean localDataSource) Set totrueto cause the datasource to be looked up in the webapp JNDI Context.- Parameters:
localDataSource- the new flag value
-
expiredKeys
Description copied from class:StoreBaseGet only those keys of sessions, that are saved in the Store and are to be expired.- Overrides:
expiredKeysin classStoreBase- Returns:
- list of session keys, that are to be expired
- Throws:
IOException- if an input-/output error occurred
-
keys
- Returns:
- an array containing the session identifiers of all Sessions currently saved in this Store. If there are no such Sessions, a zero-length array is returned.
- Throws:
IOException- if an input/output error occurred
-
getSize
- Returns:
- the number of Sessions present in this Store.
- Throws:
IOException- if an input/output error occurs
-
load
Description copied from interface:StoreLoad and return the Session associated with the specified session identifier from this Store, without removing it. If there is no such stored Session, returnnull.- Parameters:
id- Session identifier of the session to load- Returns:
- the loaded Session instance
- Throws:
ClassNotFoundException- if a deserialization error occursIOException- if an input/output error occurs
-
remove
Description copied from interface:StoreRemove the Session with the specified session identifier from this Store, if present. If no such Session is present, this method takes no action.- Parameters:
id- Session identifier of the Session to be removed- Throws:
IOException- if an input/output error occurs
-
clear
Description copied from interface:StoreRemove all Sessions from this Store.- Throws:
IOException- if an input/output error occurs
-
save
Description copied from interface:StoreSave the specified Session into this Store. Any previously saved information for the associated session identifier is replaced.- Parameters:
session- Session to be saved- Throws:
IOException- if an input/output error occurs
-
getConnection
Check the connection associated with this store, if it'snullor closed try to reopen it. Returnsnullif the connection could not be established.- Returns:
Connectionif the connection succeeded
-
open
Open (if necessary) and return a database connection for use by this Store.- Returns:
- database connection ready to use
- Throws:
SQLException- if a database error occurs
-
close
Close the specified database connection.- Parameters:
dbConnection- The connection to be closed
-
release
Release the connection, if it is associated with a connection pool.- Parameters:
conn- The connection to be released
-