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 intdebugThe debugging detail level for this component.protected StringinfoThe descriptive information about this implementation.protected LifecycleSupportlifecycleThe lifecycle event support for this component.protected ManagermanagerThe Manager with which this JDBCStore is associated.protected booleanstartedHas this component been started yet?protected StringstoreNameName to register for this Store, used for logging.protected PropertyChangeSupportsupportThe 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 voidaddLifecycleListener(LifecycleListener listener)Add a lifecycle event listener to this component.voidaddPropertyChangeListener(PropertyChangeListener listener)Add a property change listener to this component.voiddoProcessExpires()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.intgetDebug()Return the debugging detail level for this Store.StringgetInfo()Return the info for this Store.ManagergetManager()Return the Manager with which the Store is associated.StringgetStoreName()Return the name for this Store, used for logging.Sessionload(String id, String version)Load and return the Session associated with the specified session identifier from this Store, without removing it.protected voidlog(String message)Log a message on the Logger associated with our Container (if any).voidprocessExpires()Called by our background reaper thread to check if Sessions saved in our store are subject of being expired.SessionreadSession(Manager manager, ObjectInputStream ois)Create a session object from an input stream.voidremoveFromStoreCache(String id)no-op method - sub classes will implement to remove a session from the store cache Hercules: added methodvoidremoveLifecycleListener(LifecycleListener listener)Remove a lifecycle event listener from this component.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove a property change listener from this component.voidsetDebug(int debug)Set the debugging detail level for this Store.voidsetManager(Manager manager)Set the Manager with which this Store is associated.voidstart()Prepare for the beginning of active use of the public methods of this component.voidstop()Gracefully terminate the active use of the public methods of this component.voidwriteSession(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:
setManagerin interfaceStore- Parameters:
manager- The newly associated Manager
-
getManager
public Manager getManager()
Return the Manager with which the Store is associated.- Specified by:
getManagerin interfaceStore
-
addLifecycleListener
public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.- Specified by:
addLifecycleListenerin 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:
findLifecycleListenersin interfaceLifecycle
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.- Specified by:
removeLifecycleListenerin interfaceLifecycle- Parameters:
listener- The listener to add
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.- Specified by:
addPropertyChangeListenerin interfaceStore- Parameters:
listener- a value of type 'PropertyChangeListener'
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.- Specified by:
removePropertyChangeListenerin 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:
ClassNotFoundExceptionIOException
-
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 LifecycleExceptionPrepare 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:
startin interfaceLifecycle- Throws:
LifecycleException- if this component detects a fatal error that prevents this component from being used
-
stop
public void stop() throws LifecycleExceptionGracefully 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:
stopin interfaceLifecycle- Throws:
LifecycleException- if this component detects a fatal error that needs to be reported
-
-