Class FileStore

  • All Implemented Interfaces:
    Lifecycle, Store

    public final class FileStore
    extends StoreBase
    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
    • Constructor Detail

      • FileStore

        public FileStore()
    • Method Detail

      • getDirectory

        public java.lang.String getDirectory()
        Returns:
        The directory path for this Store.
      • setDirectory

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

        public java.lang.String getThreadName()
        Returns:
        The thread name for this Store.
      • getStoreName

        public java.lang.String getStoreName()
        Return the name for this Store, used for logging.
        Overrides:
        getStoreName in class StoreBase
        Returns:
        the name for this Store, used for logging.
      • getSize

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

        public void clear()
                   throws java.io.IOException
        Remove all of the Sessions in this Store.
        Throws:
        java.io.IOException - if an input/output error occurs
      • 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.
        Returns:
        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.
        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.
        Parameters:
        id - Session identifier of the session to load
        Returns:
        the loaded Session instance
        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.
        Parameters:
        id - Session identifier of the Session to be removed
        Throws:
        java.io.IOException - if an input/output error occurs
      • 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.
        Parameters:
        session - Session to be saved
        Throws:
        java.io.IOException - if an input/output error occurs