Class MultiUserDbPool

java.lang.Object
org.tentackle.dbms.MultiUserDbPool
All Implemented Interfaces:
MultiUserSessionPool

public class MultiUserDbPool extends Object implements MultiUserSessionPool
Implementation of a MultiUserSessionPool.
The pool is actually a pool of DbPools, one for each SessionInfo.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultiUserDbPool(String name, ConnectionManager conMgr, int sessionGroupId, int maximumSize, int maximumTotalSize, long idleMinutes, long usageMinutes)
    Creates a multi-user session pool.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close(SessionInfo sessionInfo)
    Closes all sessions currently open for given session info.
    Useful to force logout for a user.
    It is not an error if there were no open sessions for the session info at all.
    protected boolean
    Determines whether the next session to open should be cloned or not.
    get(SessionInfo sessionInfo)
    Gets a session from the pool for given session info.
    int
    Gets the maximum pool size per session info.
    int
    Gets the maximum pool size for all sessions.
    Gets the name of this pool.
    int
    Gets the current number of session instances.
    boolean
    Returns whether the pool is shutdown.
    protected boolean
    Determines whether the given pooled session can be removed from the pool due to timeout.
    This method is provided to override the default in DbPool, which is used a private subclass in MultiUserDbPool.
    void
    put(Session session)
    Returns a session to the pool.
    Returning a closed session will remove it from the pool.
    void
    Closes all sessions in the pool, cleans up, and makes the pool unusable.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MultiUserDbPool

      public MultiUserDbPool(String name, ConnectionManager conMgr, int sessionGroupId, int maximumSize, int maximumTotalSize, long idleMinutes, long usageMinutes)
      Creates a multi-user session pool.
      Parameters:
      name - the name of the pool, null if "default-multi"
      conMgr - the connection manager for local sessions, null if remote
      sessionGroupId - the session group ID to use for all sessions
      maximumSize - the maximum number of sessions per session info, 0 = unlimited
      maximumTotalSize - the maximum total number of sessions, 0 = unlimited
      idleMinutes - the idle timeout in minutes to close unused sessions per session info, 0 = unlimited
      usageMinutes - the maximum used time in minutes per session info, 0 = unlimited
  • Method Details

    • get

      public Session get(SessionInfo sessionInfo)
      Description copied from interface: MultiUserSessionPool
      Gets a session from the pool for given session info.
      Specified by:
      get in interface MultiUserSessionPool
      Parameters:
      sessionInfo - the session info
      Returns:
      the session, never null
    • put

      public void put(Session session)
      Description copied from interface: MultiUserSessionPool
      Returns a session to the pool.
      Returning a closed session will remove it from the pool.
      Specified by:
      put in interface MultiUserSessionPool
      Parameters:
      session - the session
    • close

      public void close(SessionInfo sessionInfo)
      Description copied from interface: MultiUserSessionPool
      Closes all sessions currently open for given session info.
      Useful to force logout for a user.
      It is not an error if there were no open sessions for the session info at all.
      Specified by:
      close in interface MultiUserSessionPool
      Parameters:
      sessionInfo - the session info
    • getName

      public String getName()
      Description copied from interface: MultiUserSessionPool
      Gets the name of this pool.
      Specified by:
      getName in interface MultiUserSessionPool
      Returns:
      the name
    • getMaximumSize

      public int getMaximumSize()
      Description copied from interface: MultiUserSessionPool
      Gets the maximum pool size per session info.
      Specified by:
      getMaximumSize in interface MultiUserSessionPool
      Returns:
      the max. number of concurrent session instances, 0 = unlimited
    • getMaximumTotalSize

      public int getMaximumTotalSize()
      Description copied from interface: MultiUserSessionPool
      Gets the maximum pool size for all sessions.
      Specified by:
      getMaximumTotalSize in interface MultiUserSessionPool
      Returns:
      the max. number of concurrent session instances, 0 = unlimited
    • getSize

      public int getSize()
      Description copied from interface: MultiUserSessionPool
      Gets the current number of session instances.
      Specified by:
      getSize in interface MultiUserSessionPool
      Returns:
      the number of sessions managed by this pool
    • shutdown

      public void shutdown()
      Description copied from interface: MultiUserSessionPool
      Closes all sessions in the pool, cleans up, and makes the pool unusable.
      Specified by:
      shutdown in interface MultiUserSessionPool
    • isShutdown

      public boolean isShutdown()
      Description copied from interface: MultiUserSessionPool
      Returns whether the pool is shutdown.
      Specified by:
      isShutdown in interface MultiUserSessionPool
      Returns:
      true if shutdown
    • determineSessionCloned

      protected boolean determineSessionCloned(SessionInfo sessionInfo, DbPool pool)
      Determines whether the next session to open should be cloned or not.
      Parameters:
      sessionInfo - the session info requested
      pool - the session pool for the given session info
      Returns:
      true to be cloned
    • isSlotRemovable

      protected boolean isSlotRemovable(PoolSlot<Session> slot)
      Determines whether the given pooled session can be removed from the pool due to timeout.
      This method is provided to override the default in DbPool, which is used a private subclass in MultiUserDbPool.
      Parameters:
      slot - the pool's session slot
      Returns:
      true if it can be removed