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 maxSize, int maxTotalSize, long maxIdleMinutes, long maxUsageMinutes)
    Creates a multi-user session pool.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close(SessionInfo sessionInfo)
    Closes all sessions currently open for a 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 a 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.
    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.
    boolean
    Returns whether the pool is shutdown.
    void
    put(Session session)
    Returns a session back 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 java.lang.Object

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

    • MultiUserDbPool

      public MultiUserDbPool(String name, ConnectionManager conMgr, int sessionGroupId, int maxSize, int maxTotalSize, long maxIdleMinutes, long maxUsageMinutes)
      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
      maxSize - the maximum number of sessions per session info, 0 = unlimited
      maxTotalSize - the maximum total number of sessions, 0 = unlimited
      maxIdleMinutes - the idle timeout in minutes to close unused sessions per session info, 0 = unlimited
      maxUsageMinutes - the max. 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 a 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 back 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 a 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
    • getMaxSize

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

      public int getMaxTotalSize()
      Description copied from interface: MultiUserSessionPool
      Gets the maximum pool size for all sessions.
      Specified by:
      getMaxTotalSize 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
    • isPooledDbRemovable

      protected boolean isPooledDbRemovable(PooledDb pooledDb)
      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:
      pooledDb - the pooled session
      Returns:
      true if it can be removed