Package org.apache.catalina.session
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
Fields Modifier and Type Field Description protected javax.sql.DataSource
dataSource
DataSource to useprotected java.lang.String
dataSourceName
name of the JNDI resourceprotected java.lang.String
sessionAppCol
Column to use for /Engine/Host/Context nameprotected java.lang.String
sessionDataCol
Data column to use.protected java.lang.String
sessionIdCol
Id column to use.protected java.lang.String
sessionLastAccessedCol
Last Accessed column to use.protected java.lang.String
sessionMaxInactiveCol
Max Inactive column to use.protected java.lang.String
sessionTable
Table to use.protected java.lang.String
sessionValidCol
Is Valid
column to use.protected static java.lang.String
storeName
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
Constructors Constructor Description DataSourceStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Remove all of the Sessions in this Store.protected void
close(java.sql.Connection dbConnection)
Close the specified database connection.java.lang.String[]
expiredKeys()
Get only those keys of sessions, that are saved in the Store and are to be expired.protected java.sql.Connection
getConnection()
Check the connection associated with this store, if it'snull
or closed try to reopen it.java.lang.String
getDataSourceName()
boolean
getLocalDataSource()
java.lang.String
getName()
java.lang.String
getSessionAppCol()
java.lang.String
getSessionDataCol()
java.lang.String
getSessionIdCol()
java.lang.String
getSessionLastAccessedCol()
java.lang.String
getSessionMaxInactiveCol()
java.lang.String
getSessionTable()
java.lang.String
getSessionValidCol()
int
getSize()
Return an integer containing a count of all Sessions currently saved in this Store.java.lang.String
getStoreName()
java.lang.String[]
keys()
Session
load(java.lang.String id)
Load the Session associated with the idid
.protected java.sql.Connection
open()
Open (if necessary) and return a database connection for use by this Store.protected void
release(java.sql.Connection conn)
Release the connection, if it is associated with a connection pool.void
remove(java.lang.String id)
Remove the Session with the specified session identifier from this Store, if present.void
save(Session session)
Save a session to the Store.void
setDataSourceName(java.lang.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(java.lang.String sessionAppCol)
Set the App column for the table.void
setSessionDataCol(java.lang.String sessionDataCol)
Set the Data column for the tablevoid
setSessionIdCol(java.lang.String sessionIdCol)
Set the Id column for the table.void
setSessionLastAccessedCol(java.lang.String sessionLastAccessedCol)
Set theLast Accessed
column for the tablevoid
setSessionMaxInactiveCol(java.lang.String sessionMaxInactiveCol)
Set theMax Inactive
column for the tablevoid
setSessionTable(java.lang.String sessionTable)
Set the table for this Store.void
setSessionValidCol(java.lang.String sessionValidCol)
Set theIs Valid
column for the table-
Methods 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 Detail
-
storeName
protected static final java.lang.String storeName
Name to register for this Store, used for logging.- See Also:
- Constant Field Values
-
dataSourceName
protected java.lang.String dataSourceName
name of the JNDI resource
-
dataSource
protected javax.sql.DataSource dataSource
DataSource to use
-
sessionTable
protected java.lang.String sessionTable
Table to use.
-
sessionAppCol
protected java.lang.String sessionAppCol
Column to use for /Engine/Host/Context name
-
sessionIdCol
protected java.lang.String sessionIdCol
Id column to use.
-
sessionDataCol
protected java.lang.String sessionDataCol
Data column to use.
-
sessionValidCol
protected java.lang.String sessionValidCol
Is Valid
column to use.
-
sessionMaxInactiveCol
protected java.lang.String sessionMaxInactiveCol
Max Inactive column to use.
-
sessionLastAccessedCol
protected java.lang.String sessionLastAccessedCol
Last Accessed column to use.
-
-
Method Detail
-
getName
public java.lang.String getName()
- Returns:
- the name for this instance (built from container name)
-
getStoreName
public java.lang.String getStoreName()
- Overrides:
getStoreName
in classStoreBase
- Returns:
- the name for this Store, used for logging.
-
setSessionTable
public void setSessionTable(java.lang.String sessionTable)
Set the table for this Store.- Parameters:
sessionTable
- The new table
-
getSessionTable
public java.lang.String getSessionTable()
- Returns:
- the table for this Store.
-
setSessionAppCol
public void setSessionAppCol(java.lang.String sessionAppCol)
Set the App column for the table.- Parameters:
sessionAppCol
- the column name
-
getSessionAppCol
public java.lang.String getSessionAppCol()
- Returns:
- the web application name column for the table.
-
setSessionIdCol
public void setSessionIdCol(java.lang.String sessionIdCol)
Set the Id column for the table.- Parameters:
sessionIdCol
- the column name
-
getSessionIdCol
public java.lang.String getSessionIdCol()
- Returns:
- the Id column for the table.
-
setSessionDataCol
public void setSessionDataCol(java.lang.String sessionDataCol)
Set the Data column for the table- Parameters:
sessionDataCol
- the column name
-
getSessionDataCol
public java.lang.String getSessionDataCol()
- Returns:
- the data column for the table
-
setSessionValidCol
public void setSessionValidCol(java.lang.String sessionValidCol)
Set theIs Valid
column for the table- Parameters:
sessionValidCol
- The column name
-
getSessionValidCol
public java.lang.String getSessionValidCol()
- Returns:
- the
Is Valid
column
-
setSessionMaxInactiveCol
public void setSessionMaxInactiveCol(java.lang.String sessionMaxInactiveCol)
Set theMax Inactive
column for the table- Parameters:
sessionMaxInactiveCol
- The column name
-
getSessionMaxInactiveCol
public java.lang.String getSessionMaxInactiveCol()
- Returns:
- the
Max Inactive
column
-
setSessionLastAccessedCol
public void setSessionLastAccessedCol(java.lang.String sessionLastAccessedCol)
Set theLast Accessed
column for the table- Parameters:
sessionLastAccessedCol
- The column name
-
getSessionLastAccessedCol
public java.lang.String getSessionLastAccessedCol()
- Returns:
- the
Last Accessed
column
-
setDataSourceName
public void setDataSourceName(java.lang.String dataSourceName)
Set the JNDI name of a DataSource-factory to use for db access- Parameters:
dataSourceName
- The JNDI name of the DataSource-factory
-
getDataSourceName
public java.lang.String 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
public java.lang.String[] expiredKeys() throws java.io.IOException
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:
java.io.IOException
- if an input-/output error occurred
-
keys
public java.lang.String[] keys() throws java.io.IOException
- 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:
java.io.IOException
- if an input/output error occurred
-
getSize
public int getSize() throws java.io.IOException
Return an integer containing a count of all Sessions currently saved in this Store. If there are no Sessions,0
is returned.- Returns:
- the count of all sessions currently saved in this Store
- Throws:
java.io.IOException
- if an input/output error occurred
-
load
public Session load(java.lang.String id) throws java.lang.ClassNotFoundException, java.io.IOException
Load the Session associated with the idid
. If no such session is foundnull
is returned.- Parameters:
id
- a value of typeString
- Returns:
- the stored
Session
- Throws:
java.lang.ClassNotFoundException
- if an error occursjava.io.IOException
- if an input/output error occurred
-
remove
public void remove(java.lang.String id) throws java.io.IOException
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:
java.io.IOException
- if an input/output error occurs
-
clear
public void clear() throws java.io.IOException
Remove all of the Sessions in this Store.- Throws:
java.io.IOException
- if an input/output error occurs
-
save
public void save(Session session) throws java.io.IOException
Save a session to the Store.- Parameters:
session
- the session to be stored- Throws:
java.io.IOException
- if an input/output error occurs
-
getConnection
protected java.sql.Connection 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
protected java.sql.Connection open() throws java.sql.SQLException
Open (if necessary) and return a database connection for use by this Store.- Returns:
- database connection ready to use
- Throws:
java.sql.SQLException
- if a database error occurs
-
close
protected void close(java.sql.Connection dbConnection)
Close the specified database connection.- Parameters:
dbConnection
- The connection to be closed
-
release
protected void release(java.sql.Connection conn)
Release the connection, if it is associated with a connection pool.- Parameters:
conn
- The connection to be released
-
-