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.
  • Constructor Details

    • DataSourceStore

      public DataSourceStore()
  • Method Details

    • expiredKeys

      public String[] expiredKeys() throws IOException
      Description copied from class: StoreBase
      Get the keys of sessions that are to be expired. The default implementation returns all keys that are saved in the Store. Subclasses may override this to return only the keys of sessions that are actually to be expired.
      Overrides:
      expiredKeys in class JDBCStore
      Returns:
      array of session keys
      Throws:
      IOException - if an input-/output error occurred
    • keys

      public String[] keys() throws IOException
      Description copied from interface: Store
      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
      Overrides:
      keys in class JDBCStore
      Returns:
      the session identifiers
      Throws:
      IOException - if an input/output error occurred
    • getSize

      public int getSize() throws IOException
      Description copied from class: JDBCStore
      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
    • load

      Description copied from class: JDBCStore
      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:
      ClassNotFoundException - if an error occurs
      IOException - if an input/output error occurred
    • remove

      public void remove(String id) throws IOException
      Description copied from class: JDBCStore
      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
    • clear

      public void clear() throws IOException
      Description copied from class: JDBCStore
      Remove all of the Sessions in this Store.
      Specified by:
      clear in interface Store
      Overrides:
      clear in class JDBCStore
      Throws:
      IOException - if an input/output error occurs
    • save

      public void save(Session session) throws IOException
      Description copied from class: JDBCStore
      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