Package org.apache.catalina.session
Class StoreBase
- java.lang.Object
-
- org.apache.catalina.session.StoreBase
-
- Direct Known Subclasses:
FileStore
,HAStoreBase
,JDBCStore
public abstract class StoreBase extends Object implements Lifecycle, Store
Abstract implementation of the Store interface to support most of the functionality required by a Store.- Version:
- $Revision: 1.8 $, $Date: 2007/05/05 05:32:19 $
- Author:
- Bip Thelin
-
-
Field Summary
Fields Modifier and Type Field Description protected int
debug
The debugging detail level for this component.protected String
info
The descriptive information about this implementation.protected LifecycleSupport
lifecycle
The lifecycle event support for this component.protected Manager
manager
The Manager with which this JDBCStore is associated.protected boolean
started
Has this component been started yet?protected String
storeName
Name to register for this Store, used for logging.protected PropertyChangeSupport
support
The property change support for this component.-
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, INIT_EVENT, START_EVENT, STOP_EVENT
-
-
Constructor Summary
Constructors Constructor Description StoreBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.void
addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.void
doProcessExpires()
public wrapper for processExpires() don't want to make processExpires() public called from manager background thread Hercules: added methodList<LifecycleListener>
findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this Store.int
getDebug()
Return the debugging detail level for this Store.String
getInfo()
Return the info for this Store.Manager
getManager()
Return the Manager with which the Store is associated.String
getStoreName()
Return the name for this Store, used for logging.Session
load(String id, String version)
Load and return the Session associated with the specified session identifier from this Store, without removing it.protected void
log(String message)
Log a message on the Logger associated with our Container (if any).void
processExpires()
Called by our background reaper thread to check if Sessions saved in our store are subject of being expired.Session
readSession(Manager manager, ObjectInputStream ois)
Create a session object from an input stream.void
removeFromStoreCache(String id)
no-op method - sub classes will implement to remove a session from the store cache Hercules: added methodvoid
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.void
removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.void
setDebug(int debug)
Set the debugging detail level for this Store.void
setManager(Manager manager)
Set the Manager with which this Store is associated.void
start()
Prepare for the beginning of active use of the public methods of this component.void
stop()
Gracefully terminate the active use of the public methods of this component.void
writeSession(Session sess, ObjectOutputStream oos)
Serialize a session into an output stream.
-
-
-
Field Detail
-
info
protected String info
The descriptive information about this implementation.
-
storeName
protected String storeName
Name to register for this Store, used for logging.
-
debug
protected int debug
The debugging detail level for this component.
-
started
protected boolean started
Has this component been started yet?
-
lifecycle
protected LifecycleSupport lifecycle
The lifecycle event support for this component.
-
support
protected PropertyChangeSupport support
The property change support for this component.
-
manager
protected Manager manager
The Manager with which this JDBCStore is associated.
-
-
Method Detail
-
getInfo
public String getInfo()
Return the info for this Store.
-
getStoreName
public String getStoreName()
Return the name for this Store, used for logging.
-
setDebug
public void setDebug(int debug)
Set the debugging detail level for this Store.- Parameters:
debug
- The new debugging detail level
-
getDebug
public int getDebug()
Return the debugging detail level for this Store.
-
setManager
public void setManager(Manager manager)
Set the Manager with which this Store is associated.- Specified by:
setManager
in interfaceStore
- Parameters:
manager
- The newly associated Manager
-
getManager
public Manager getManager()
Return the Manager with which the Store is associated.- Specified by:
getManager
in interfaceStore
-
addLifecycleListener
public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.- Specified by:
addLifecycleListener
in interfaceLifecycle
- Parameters:
listener
- The listener to add
-
findLifecycleListeners
public List<LifecycleListener> findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this Store.- Specified by:
findLifecycleListeners
in interfaceLifecycle
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.- Specified by:
removeLifecycleListener
in interfaceLifecycle
- Parameters:
listener
- The listener to add
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.- Specified by:
addPropertyChangeListener
in interfaceStore
- Parameters:
listener
- a value of type 'PropertyChangeListener'
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.- Specified by:
removePropertyChangeListener
in interfaceStore
- Parameters:
listener
- The listener to remove
-
writeSession
public void writeSession(Session sess, ObjectOutputStream oos) throws IOException
Serialize a session into an output stream.- Parameters:
sess
- The session to be serializedoos
- The output stream the session should be written to Hercules: added method- Throws:
IOException
-
readSession
public Session readSession(Manager manager, ObjectInputStream ois) throws ClassNotFoundException, IOException
Create a session object from an input stream.- Parameters:
manager
- The manager that will own this sessionois
- The input stream containing the serialized session- Returns:
- The resulting session object Hercules: added method
- Throws:
ClassNotFoundException
IOException
-
doProcessExpires
public void doProcessExpires()
public wrapper for processExpires() don't want to make processExpires() public called from manager background thread Hercules: added method
-
removeFromStoreCache
public void removeFromStoreCache(String id)
no-op method - sub classes will implement to remove a session from the store cache Hercules: added method
-
processExpires
public void processExpires()
Called by our background reaper thread to check if Sessions saved in our store are subject of being expired. If so expire the Session and remove it from the Store.
-
log
protected void log(String message)
Log a message on the Logger associated with our Container (if any).- Parameters:
message
- Message to be logged
-
load
public Session load(String id, String version) throws ClassNotFoundException, IOException
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 loadversion
- The requested session version- Throws:
ClassNotFoundException
- if a deserialization error occursIOException
- if an input/output error occurs
-
start
public void start() throws LifecycleException
Prepare for the beginning of active use of the public methods of this component. This method should be called afterconfigure()
, and before any of the public methods of the component are utilized.- Specified by:
start
in interfaceLifecycle
- Throws:
LifecycleException
- if this component detects a fatal error that prevents this component from being used
-
stop
public void stop() throws LifecycleException
Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.- Specified by:
stop
in interfaceLifecycle
- Throws:
LifecycleException
- if this component detects a fatal error that needs to be reported
-
-