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 java.lang.String[] expiredKeys()
                                       throws java.io.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:
        java.io.IOException - if an input-/output error occurred
      • keys

        public java.lang.String[] keys()
                                throws java.io.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:
        java.io.IOException - if an input/output error occurred
      • getSize

        public int getSize()
                    throws java.io.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:
        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 the Session associated with the id id. If no such session is found null is returned.
        Specified by:
        load in interface Store
        Overrides:
        load in class JDBCStore
        Parameters:
        id - a value of type String
        Returns:
        the stored Session
        Throws:
        java.lang.ClassNotFoundException - if an error occurs
        java.io.IOException - if an input/output error occurred
      • 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
        Overrides:
        remove in class JDBCStore
        Parameters:
        id - Session identifier of the Session to be removed
        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.
        Specified by:
        clear in interface Store
        Overrides:
        clear in class JDBCStore
        Throws:
        java.io.IOException - if an input/output error occurs
      • save

        public void save​(Session session)
                  throws java.io.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:
        java.io.IOException - if an input/output error occurs
      • open

        protected java.sql.Connection open()
                                    throws java.sql.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:
        java.sql.SQLException - if a database error occurs
      • close

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