Top Description Fields Constructors Methods
org.apache.catalina.session

public final Class FileStore

extends StoreBase
Class Inheritance
Imports
java.io.BufferedOutputStream, .File, .FileInputStream, .FileNotFoundException, .FileOutputStream, .IOException, .ObjectInputStream, .ObjectOutputStream, java.util.ArrayList, .List, jakarta.servlet.ServletContext, org.apache.catalina.Context, .Globals, .Session, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.res.StringManager

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.
Author
Craig R. McClanahan

Field Summary

Modifier and TypeField and Description
private String
directory

The pathname of the directory in which Sessions are stored.

private File
directoryFile

A File representing the directory in which Sessions are stored.

private static final String
FILE_EXT

The extension to use for serialized session filenames.

private static final Log
private static final StringManager
private static final String
storeName

Hides org.apache.catalina.session.StoreBase.storeName.

Name to register for this Store, used for logging.
private static final String
threadName

Name to register for the background thread.

Inherited from org.apache.catalina.session.StoreBase:
managersupport

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements org.apache.catalina.Store.clear.

Remove all of the Sessions in this Store.

private File
directory()

Return a File object representing the pathname to our session persistence directory, if any.

private File
file(String
The ID of the Session to be retrieved. This is used in the file naming.
id
)

Return a File object representing the pathname to our session persistence file, if any.

public String

Returns:

The directory path for this Store.
getDirectory
()

public int
getSize()

Implements org.apache.catalina.Store.getSize.

Return the number of Sessions present in this Store.

public String
getStoreName()

Overrides org.apache.catalina.session.StoreBase.getStoreName.

Return the name for this Store, used for logging.

public String

Returns:

The thread name for this Store.
getThreadName
()

public String[]
keys()

Implements org.apache.catalina.Store.keys.

Return an array containing the session identifiers of all Sessions currently saved in this Store.

public Session
load(String
Session identifier of the session to load
id
)

Implements org.apache.catalina.Store.load.

Load and return the Session associated with the specified session identifier from this Store, without removing it.

public void
remove(String
Session identifier of the Session to be removed
id
)

Implements org.apache.catalina.Store.remove.

Remove the Session with the specified session identifier from this Store, if present.

public void
save(Session
Session to be saved
session
)

Implements org.apache.catalina.Store.save.

Save the specified Session into this Store.

public void
setDirectory(String
The new directory path
path
)

Set the directory path for this Store.

Inherited from org.apache.catalina.session.StoreBase:
addPropertyChangeListenerdestroyInternalexpiredKeysgetManagergetObjectInputStreaminitInternalprocessExpiresremovePropertyChangeListenersetManagerstartInternalstopInternaltoString

Field Detail

directoryback to summary
private String directory

The pathname of the directory in which Sessions are stored. This may be an absolute pathname, or a relative path that is resolved against the temporary work directory for this application.

directoryFileback to summary
private File directoryFile

A File representing the directory in which Sessions are stored.

FILE_EXTback to summary
private static final String FILE_EXT

The extension to use for serialized session filenames.

logback to summary
private static final Log log

Hides org.apache.catalina.util.LifecycleBase.log.

smback to summary
private static final StringManager sm

Hides org.apache.catalina.session.StoreBase.sm.

storeNameback to summary
private static final String storeName

Hides org.apache.catalina.session.StoreBase.storeName.

Name to register for this Store, used for logging.

threadNameback to summary
private static final String threadName

Name to register for the background thread.

Constructor Detail

FileStoreback to summary
public FileStore()

Method Detail

clearback to summary
public void clear() throws IOException

Implements org.apache.catalina.Store.clear.

Remove all of the Sessions in this Store.

Annotations
@Override
Exceptions
IOException:
if an input/output error occurs
directoryback to summary
private File directory() throws IOException

Return a File object representing the pathname to our session persistence directory, if any. The directory will be created if it does not already exist.

fileback to summary
private File file(String id) throws IOException

Return a File object representing the pathname to our session persistence file, if any.

Parameters
id:String

The ID of the Session to be retrieved. This is used in the file naming.

getDirectoryback to summary
public String getDirectory()
Returns:String

The directory path for this Store.

getSizeback to summary
public int getSize() throws IOException

Implements org.apache.catalina.Store.getSize.

Return the number of Sessions present in this Store.

Returns:int

Doc from org.apache.catalina.Store.getSize.

the number of Sessions present in this Store.

Annotations
@Override
Exceptions
IOException:
if an input/output error occurs
getStoreNameback to summary
public String getStoreName()

Overrides org.apache.catalina.session.StoreBase.getStoreName.

Return the name for this Store, used for logging.

Returns:String

Doc from org.apache.catalina.session.StoreBase.getStoreName.

the name for this Store, used for logging.

Annotations
@Override
getThreadNameback to summary
public String getThreadName()
Returns:String

The thread name for this Store.

keysback to summary
public String[] keys() throws IOException

Implements org.apache.catalina.Store.keys.

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.

Returns:String[]

Doc from org.apache.catalina.Store.keys.

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.

Annotations
@Override
Exceptions
IOException:
if an input/output error occurred
loadback to summary
public Session load(String id) throws ClassNotFoundException, IOException

Implements org.apache.catalina.Store.load.

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.

Parameters
id:String

Session identifier of the session to load

Returns:Session

Doc from org.apache.catalina.Store.load.

the loaded Session instance

Annotations
@Override
Exceptions
ClassNotFoundException:
if a deserialization error occurs
IOException:
if an input/output error occurs
removeback to summary
public void remove(String id) throws IOException

Implements org.apache.catalina.Store.remove.

Remove the Session with the specified session identifier from this Store, if present. If no such Session is present, this method takes no action.

Parameters
id:String

Session identifier of the Session to be removed

Annotations
@Override
Exceptions
IOException:
if an input/output error occurs
saveback to summary
public void save(Session session) throws IOException

Implements org.apache.catalina.Store.save.

Save the specified Session into this Store. Any previously saved information for the associated session identifier is replaced.

Parameters
session:Session

Session to be saved

Annotations
@Override
Exceptions
IOException:
if an input/output error occurs
setDirectoryback to summary
public void setDirectory(String path)

Set the directory path for this Store.

Parameters
path:String

The new directory path