public class JDBCStore extends StoreBase
Store
interface that stores
serialized session objects in a database. Sessions that are
saved are still subject to being expired based on inactivity.Modifier and Type | Field and Description |
---|---|
protected String |
connString
Connection string to use when connecting to the DB.
|
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.
|
debug, lifecycle, manager, started, support
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, INIT_EVENT, START_EVENT, STOP_EVENT
Constructor and Description |
---|
JDBCStore() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all of the Sessions in this Store.
|
protected Connection |
getConnection()
Check the connection associated with this store, if it's
null or closed try to reopen it. |
String |
getConnectionURL()
Return the Connection URL for this Store.
|
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 void |
release(Connection conn)
Release the connection, not needed here since the
connection is not 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 |
setConnectionURL(String connectionURL)
Set the Connection URL for this Store.
|
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
|
void |
start()
Called once when this Store is first started.
|
void |
stop()
Gracefully terminate everything associated with our db.
|
addLifecycleListener, addPropertyChangeListener, doProcessExpires, findLifecycleListeners, getDebug, getManager, load, log, processExpires, readSession, removeFromStoreCache, removeLifecycleListener, removePropertyChangeListener, setDebug, setManager, writeSession
protected static final String info
protected static final String storeName
protected String threadName
protected String connString
protected String driverName
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.public String getInfo()
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 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 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 occursIOException
- if an input/output error occurredpublic void remove(String id) throws IOException
id
- Session identifier of the Session to be removedIOException
- 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 storedIOException
- 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 void release(Connection conn)
conn
- The connection to be releasedpublic void start() throws LifecycleException
start
in interface Lifecycle
start
in class StoreBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedpublic void stop() throws LifecycleException
stop
in interface Lifecycle
stop
in class StoreBase
LifecycleException
- if this component detects a fatal error
that needs to be reportedCopyright © 2019. All rights reserved.