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
Modifier and TypeFieldDescriptionprotected DataSource
DataSource to useprotected String
name of the JNDI resourceprotected String
Column to use for /Engine/Host/Context nameprotected String
Data column to use.protected String
Id column to use.protected String
Last Accessed column to use.protected String
Max Inactive column to use.protected String
Table to use.protected String
Is Valid
column to use.protected static final String
Name 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Remove all Sessions from this Store.protected void
close
(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 Connection
Check the connection associated with this store, if it'snull
or closed try to reopen it.boolean
getName()
int
getSize()
String[]
keys()
Load and return the Session associated with the specified session identifier from this Store, without removing it.protected Connection
open()
Open (if necessary) and return a database connection for use by this Store.protected void
release
(Connection conn) Release the connection, if it is associated with a connection pool.void
Remove the Session with the specified session identifier from this Store, if present.void
Save the specified Session into this Store.void
setDataSourceName
(String dataSourceName) Set the JNDI name of a DataSource-factory to use for db accessvoid
setLocalDataSource
(boolean localDataSource) Set totrue
to cause the datasource to be looked up in the webapp JNDI Context.void
setSessionAppCol
(String sessionAppCol) Set the App column for the table.void
setSessionDataCol
(String sessionDataCol) Set the Data column for the tablevoid
setSessionIdCol
(String sessionIdCol) Set the Id column for the table.void
setSessionLastAccessedCol
(String sessionLastAccessedCol) Set theLast Accessed
column for the tablevoid
setSessionMaxInactiveCol
(String sessionMaxInactiveCol) Set theMax Inactive
column for the tablevoid
setSessionTable
(String sessionTable) Set the table for this Store.void
setSessionValidCol
(String sessionValidCol) Set theIs Valid
column for the tableMethods inherited from class org.apache.catalina.session.StoreBase
addPropertyChangeListener, destroyInternal, getManager, getObjectInputStream, initInternal, processExpires, removePropertyChangeListener, setManager, startInternal, stopInternal, toString
Methods 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 Valid
column 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:
getStoreName
in 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 Valid
column for the table- Parameters:
sessionValidCol
- The column name
-
getSessionValidCol
- Returns:
- the
Is Valid
column
-
setSessionMaxInactiveCol
Set theMax Inactive
column for the table- Parameters:
sessionMaxInactiveCol
- The column name
-
getSessionMaxInactiveCol
- Returns:
- the
Max Inactive
column
-
setSessionLastAccessedCol
Set theLast Accessed
column for the table- Parameters:
sessionLastAccessedCol
- The column name
-
getSessionLastAccessedCol
- Returns:
- the
Last Accessed
column
-
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 totrue
to cause the datasource to be looked up in the webapp JNDI Context.- Parameters:
localDataSource
- the new flag value
-
expiredKeys
Description copied from class:StoreBase
Get only those keys of sessions, that are saved in the Store and are to be expired.- Overrides:
expiredKeys
in 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:Store
Load 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:Store
Remove 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:Store
Remove all Sessions from this Store.- Throws:
IOException
- if an input/output error occurs
-
save
Description copied from interface:Store
Save 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'snull
or closed try to reopen it. Returnsnull
if the connection could not be established.- Returns:
Connection
if 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
-