|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.catalina.util.LifecycleBase org.apache.catalina.session.StoreBase org.apache.catalina.session.JDBCStore
public class JDBCStore
Implementation of the Store
interface that stores
serialized session objects in a database. Sessions that are
saved are still subject to being expired based on inactivity.
Field Summary | |
---|---|
protected String |
connectionName
The connection username to use when trying to connect to the database. |
protected String |
connectionPassword
The connection URL to use when trying to connect to the database. |
protected String |
connectionURL
Connection string to use when connecting to the DB. |
protected DataSource |
dataSource
DataSource to use |
protected String |
dataSourceName
name of the JNDI resource |
protected Driver |
driver
Instance of the JDBC Driver class we use as a connection factory. |
protected String |
driverName
Driver to use. |
protected static String |
info
The descriptive information about this implementation. |
protected PreparedStatement |
preparedClearSql
Variable to hold the clear() prepared statement. |
protected PreparedStatement |
preparedKeysSql
Variable to hold the keys() prepared statement. |
protected PreparedStatement |
preparedLoadSql
Variable to hold the load() prepared statement. |
protected PreparedStatement |
preparedRemoveSql
Variable to hold the remove() prepared statement. |
protected PreparedStatement |
preparedSaveSql
Variable to hold the save() prepared statement. |
protected PreparedStatement |
preparedSizeSql
Variable to hold the getSize() prepared statement. |
protected String |
sessionAppCol
Column to use for /Engine/Host/Context name |
protected String |
sessionDataCol
Data column to use. |
protected String |
sessionIdCol
Id column to use. |
protected String |
sessionLastAccessedCol
Last Accessed column to use. |
protected String |
sessionMaxInactiveCol
Max Inactive column to use. |
protected String |
sessionTable
Table to use. |
protected String |
sessionValidCol
Is Valid column to use. |
protected static String |
storeName
Name to register for this Store, used for logging. |
protected String |
threadName
Name to register for the background thread. |
Fields inherited from class org.apache.catalina.session.StoreBase |
---|
manager, sm, support |
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 | |
---|---|
JDBCStore()
|
Method Summary | |
---|---|
void |
clear()
Remove all of the Sessions in this Store. |
protected void |
close(Connection dbConnection)
Close the specified database connection. |
protected Connection |
getConnection()
Check the connection associated with this store, if it's null or closed try to reopen it. |
String |
getConnectionName()
Return the username to use to connect to the database. |
String |
getConnectionPassword()
Return the password to use to connect to the database. |
String |
getConnectionURL()
Return the Connection URL for this Store. |
String |
getDataSourceName()
Return the name of the JNDI DataSource-factory |
String |
getDriverName()
Return the driver for this Store. |
String |
getInfo()
Return the info for this Store. |
String |
getName()
Return the name for this instance (built from container name) |
String |
getSessionAppCol()
Return the web application name column for the table. |
String |
getSessionDataCol()
Return the data column for the table |
String |
getSessionIdCol()
Return the Id column for the table. |
String |
getSessionLastAccessedCol()
Return the Last Accessed column |
String |
getSessionMaxInactiveCol()
Return the Max Inactive column |
String |
getSessionTable()
Return the table for this Store. |
String |
getSessionValidCol()
Return the Is Valid column |
int |
getSize()
Return an integer containing a count of all Sessions currently saved in this Store. |
String |
getStoreName()
Return the name for this Store, used for logging. |
String |
getThreadName()
Return the thread name for this Store. |
String[] |
keys()
Return an array containing the session identifiers of all Sessions currently saved in this Store. |
Session |
load(String id)
Load the Session associated with the id id . |
protected Connection |
open()
Open (if necessary) and return a database connection for use by this Realm. |
protected void |
release(Connection conn)
Release the connection, if it is associated with a connection pool. |
void |
remove(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 |
setConnectionName(String connectionName)
Set the username to use to connect to the database. |
void |
setConnectionPassword(String connectionPassword)
Set the password to use to connect to the database. |
void |
setConnectionURL(String connectionURL)
Set the Connection URL for this Store. |
void |
setDataSourceName(String dataSourceName)
Set the JNDI name of a DataSource-factory to use for db access |
void |
setDriverName(String driverName)
Set the driver for this Store. |
void |
setSessionAppCol(String sessionAppCol)
Set the App column for the table. |
void |
setSessionDataCol(String sessionDataCol)
Set the Data column for the table |
void |
setSessionIdCol(String sessionIdCol)
Set the Id column for the table. |
void |
setSessionLastAccessedCol(String sessionLastAccessedCol)
Set the Last Accessed column for the table |
void |
setSessionMaxInactiveCol(String sessionMaxInactiveCol)
Set the Max Inactive column for the table |
void |
setSessionTable(String sessionTable)
Set the table for this Store. |
void |
setSessionValidCol(String sessionValidCol)
Set the Is Valid column for the table |
protected void |
startInternal()
Start this component and implement the requirements of LifecycleBase.startInternal() . |
protected void |
stopInternal()
Stop this component and implement the requirements of LifecycleBase.stopInternal() . |
Methods inherited from class org.apache.catalina.session.StoreBase |
---|
addPropertyChangeListener, destroyInternal, getManager, initInternal, processExpires, removePropertyChangeListener, setManager, toString |
Methods inherited from class org.apache.catalina.util.LifecycleBase |
---|
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final String info
protected static String storeName
protected String threadName
protected String connectionName
protected String connectionPassword
protected String connectionURL
protected Driver driver
protected String driverName
protected String dataSourceName
protected DataSource dataSource
protected String sessionTable
protected String sessionAppCol
protected String sessionIdCol
protected String sessionDataCol
protected String sessionValidCol
protected String sessionMaxInactiveCol
protected String sessionLastAccessedCol
protected PreparedStatement preparedSizeSql
getSize()
prepared statement.
protected PreparedStatement preparedKeysSql
keys()
prepared statement.
protected PreparedStatement preparedSaveSql
save()
prepared statement.
protected PreparedStatement preparedClearSql
clear()
prepared statement.
protected PreparedStatement preparedRemoveSql
remove()
prepared statement.
protected PreparedStatement preparedLoadSql
load()
prepared statement.
Constructor Detail |
---|
public JDBCStore()
Method Detail |
---|
public String getInfo()
getInfo
in interface Store
getInfo
in class StoreBase
public String getName()
public String getThreadName()
public String getStoreName()
getStoreName
in class StoreBase
public void setDriverName(String driverName)
driverName
- The new driverpublic String getDriverName()
public String getConnectionName()
public void setConnectionName(String connectionName)
connectionName
- Usernamepublic String getConnectionPassword()
public void setConnectionPassword(String connectionPassword)
connectionPassword
- User passwordpublic void setConnectionURL(String connectionURL)
connectionURL
- The new Connection URLpublic String getConnectionURL()
public void setSessionTable(String sessionTable)
sessionTable
- The new tablepublic String getSessionTable()
public void setSessionAppCol(String sessionAppCol)
sessionAppCol
- the column namepublic String getSessionAppCol()
public void setSessionIdCol(String sessionIdCol)
sessionIdCol
- the column namepublic String getSessionIdCol()
public void setSessionDataCol(String sessionDataCol)
sessionDataCol
- the column namepublic String getSessionDataCol()
public void setSessionValidCol(String sessionValidCol)
sessionValidCol
- The column namepublic String getSessionValidCol()
public void setSessionMaxInactiveCol(String sessionMaxInactiveCol)
sessionMaxInactiveCol
- The column namepublic String getSessionMaxInactiveCol()
public void setSessionLastAccessedCol(String sessionLastAccessedCol)
sessionLastAccessedCol
- The column namepublic String getSessionLastAccessedCol()
public void setDataSourceName(String dataSourceName)
dataSourceName
- The JNDI name of the DataSource-factorypublic String getDataSourceName()
public String[] keys() throws IOException
IOException
- if an input/output error occurredpublic int getSize() throws IOException
0
is returned.
IOException
- if an input/output error occurredpublic Session load(String id) throws ClassNotFoundException, IOException
id
.
If no such session is found null
is returned.
id
- a value of type String
Session
ClassNotFoundException
- if an error occurs
IOException
- if an input/output error occurredpublic void remove(String id) throws IOException
id
- Session identifier of the Session to be removed
IOException
- if an input/output error occurspublic void clear() throws IOException
IOException
- if an input/output error occurspublic void save(Session session) throws IOException
session
- the session to be stored
IOException
- if an input/output error occursprotected Connection getConnection()
null
or closed try to reopen it.
Returns null
if the connection could not be established.
Connection
if the connection succeededprotected Connection open() throws SQLException
SQLException
- if a database error occursprotected void close(Connection dbConnection)
dbConnection
- The connection to be closedprotected void release(Connection conn)
conn
- The connection to be releasedprotected void startInternal() throws LifecycleException
LifecycleBase.startInternal()
.
startInternal
in class StoreBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected void stopInternal() throws LifecycleException
LifecycleBase.stopInternal()
.
stopInternal
in class StoreBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being used
|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |