Class DataSourceStore

  • All Implemented Interfaces:
    Lifecycle, Store

    public class DataSourceStore
    extends JDBCStore
    Implementation of the Store interface that stores serialized session objects in a database. Sessions that are saved are still subject to being expired based on inactivity.
    Author:
    Bip Thelin
    • Constructor Detail

      • DataSourceStore

        public DataSourceStore()
    • Method Detail

      • expiredKeys

        public String[] expiredKeys()
                             throws IOException
        Description copied from class: StoreBase
        Get only those keys of sessions, that are saved in the Store and are to be expired.
        Overrides:
        expiredKeys in class JDBCStore
        Returns:
        list of session keys, that are to be expired
        Throws:
        IOException - if an input-/output error occurred
      • keys

        public String[] keys()
                      throws IOException
        Specified by:
        keys in interface Store
        Overrides:
        keys in class JDBCStore
        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:
        IOException - if an input/output error occurred
      • getSize

        public int getSize()
                    throws IOException
        Return an integer containing a count of all Sessions currently saved in this Store. If there are no Sessions, 0 is returned.
        Specified by:
        getSize in interface Store
        Overrides:
        getSize in class JDBCStore
        Returns:
        the count of all sessions currently saved in this Store
        Throws:
        IOException - if an input/output error occurred
      • remove

        public void remove​(String id)
                    throws 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
        Overrides:
        remove in class JDBCStore
        Parameters:
        id - Session identifier of the Session to be removed
        Throws:
        IOException - if an input/output error occurs
      • save

        public void save​(Session session)
                  throws IOException
        Save a session to the Store.
        Specified by:
        save in interface Store
        Overrides:
        save in class JDBCStore
        Parameters:
        session - the session to be stored
        Throws:
        IOException - if an input/output error occurs
      • open

        protected Connection open()
                           throws SQLException
        Open (if necessary) and return a database connection for use by this Store.
        Overrides:
        open in class JDBCStore
        Returns:
        database connection ready to use
        Throws:
        SQLException - if a database error occurs
      • close

        protected void close​(Connection dbConnection)
        Close the specified database connection.
        Overrides:
        close in class JDBCStore
        Parameters:
        dbConnection - The connection to be closed