org.apache.catalina.session
Class FileStore

java.lang.Object
  |
  +--org.apache.catalina.session.FileStore
All Implemented Interfaces:
Lifecycle, java.lang.Runnable, Store

public final class FileStore
extends java.lang.Object
implements Lifecycle, java.lang.Runnable, Store

Concrete implementation of the Store interface that utilizes a file per saved Session in a configured directory. Sessions that are saved are still subject to being expired based on inactivity.

Version:
$Revision: 1.1 $ $Date: 2000/08/11 23:39:15 $
Author:
Craig R. McClanahan

Field Summary
protected  LifecycleSupport lifecycle
          The lifecycle event support for this component.
 
Fields inherited from interface org.apache.catalina.Lifecycle
START_EVENT, STOP_EVENT
 
Constructor Summary
FileStore()
           
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
          Add a lifecycle event listener to this component.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a property change listener to this component.
 int getCheckInterval()
          Return the check interval (in seconds) for this Manager.
 java.lang.String getDirectoryPath()
          Return the directory path for this Store.
 java.lang.String getInfo()
          Return descriptive information about this Store implementation and the corresponding version number, in the format <description>/<version>.
 int getSize()
          Return the number of Sessions present in this Store.
 java.lang.String[] keys()
          Return an array containing the session identifiers of all Sessions currently saved in this Store.
 Session load(java.lang.String id)
          Load and return the Session associated with the specified session identifier from this Store, without removing it.
 void remove(java.lang.String id)
          Remove the Session with the specified session identifier from this Store, if present.
 void removeLifecycleListener(LifecycleListener listener)
          Remove a lifecycle event listener from this component.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a property change listener from this component.
 void run()
          The background thread that checks for session timeouts and shutdown.
 void save(Session session)
          Save the specified Session into this Store.
 void setCheckInterval(int checkInterval)
          Set the check interval (in seconds) for this Manager.
 void setDirectoryPath(java.lang.String path)
          Set the directory path for this Store.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lifecycle

protected LifecycleSupport lifecycle
The lifecycle event support for this component.
Constructor Detail

FileStore

public FileStore()
Method Detail

getCheckInterval

public int getCheckInterval()
Return the check interval (in seconds) for this Manager.

setCheckInterval

public void setCheckInterval(int checkInterval)
Set the check interval (in seconds) for this Manager.
Parameters:
checkInterval - The new check interval

getDirectoryPath

public java.lang.String getDirectoryPath()
Return the directory path for this Store.

setDirectoryPath

public void setDirectoryPath(java.lang.String path)
Set the directory path for this Store.
Parameters:
path - The new directory path

getInfo

public java.lang.String getInfo()
Return descriptive information about this Store implementation and the corresponding version number, in the format <description>/<version>.
Specified by:
getInfo in interface Store

getSize

public int getSize()
            throws java.io.IOException
Return the number of Sessions present in this Store.
Specified by:
getSize in interface Store
Throws:
java.io.IOException - if an input/output error occurs

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to this component.
Specified by:
addPropertyChangeListener in interface Store
Parameters:
listener - The listener to add

keys

public java.lang.String[] keys()
                        throws java.io.IOException
Return 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.
Specified by:
keys in interface 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 and return the Session associated with the specified session identifier from this Store, without removing it. If there is no such stored Session, return null.
Specified by:
load in interface Store
Parameters:
id - Session identifier of the session to load
Throws:
java.lang.ClassNotFoundException - if a deserialization error occurs
java.io.IOException - if an input/output error occurs

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.
Specified by:
remove in interface Store
Parameters:
id - Session identifier of the Session to be removed
Throws:
java.io.IOException - if an input/output error occurs

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this component.
Specified by:
removePropertyChangeListener in interface Store
Parameters:
listener - The listener to remove

save

public void save(Session session)
          throws java.io.IOException
Save the specified Session into this Store. Any previously saved information for the associated session identifier is replaced.
Specified by:
save in interface Store
Parameters:
session - Session to be saved
Throws:
java.io.IOException - if an input/output error occurs

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.
Specified by:
addLifecycleListener in interface Lifecycle
Parameters:
listener - The listener to add

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.
Specified by:
removeLifecycleListener in interface Lifecycle
Parameters:
listener - The listener to add

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 after configure(), and before any of the public methods of the component are utilized.
Specified by:
start in interface Lifecycle
Throws:
IllegalStateException - if this component has already been started
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 interface Lifecycle
Throws:
IllegalStateException - if this component has not been started
LifecycleException - if this component detects a fatal error that needs to be reported

run

public void run()
The background thread that checks for session timeouts and shutdown.
Specified by:
run in interface java.lang.Runnable


Copyright © 2000 Apache Software Foundation. All Rights Reserved.