java.lang.Object
org.tentackle.dbms.MultiUserDbPool
- All Implemented Interfaces:
MultiUserSessionPool
Implementation of a
The pool is actually a pool of
MultiUserSessionPool
.The pool is actually a pool of
DbPool
s, one for each SessionInfo
.-
Constructor Summary
ConstructorDescriptionMultiUserDbPool
(String name, ConnectionManager conMgr, int sessionGroupId, int maxSize, int maxTotalSize, long maxIdleMinutes, long maxUsageMinutes) Creates a multi-user session pool. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
determineSessionCloned
(SessionInfo sessionInfo, DbPool pool) 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.getName()
Gets the name of this pool.int
getSize()
Gets the current number of session instances.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 inDbPool
, which is used a private subclass inMultiUserDbPool
.boolean
Returns whether the pool is shutdown.void
Returns a session back to the pool.
Returning a closed session will remove it from the pool.void
shutdown()
Closes all sessions in the pool, cleans up and makes the pool unusable.
-
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 remotesessionGroupId
- the session group ID to use for all sessionsmaxSize
- the maximum number of sessions per session info, 0 = unlimitedmaxTotalSize
- the maximum total number of sessions, 0 = unlimitedmaxIdleMinutes
- the idle timeout in minutes to close unused sessions per session info, 0 = unlimitedmaxUsageMinutes
- the max. used time in minutes per session info, 0 = unlimited
-
-
Method Details
-
get
Description copied from interface:MultiUserSessionPool
Gets a session from the pool for a given session info.- Specified by:
get
in interfaceMultiUserSessionPool
- Parameters:
sessionInfo
- the session info- Returns:
- the session, never null
-
put
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 interfaceMultiUserSessionPool
- Parameters:
session
- the session
-
close
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 interfaceMultiUserSessionPool
- Parameters:
sessionInfo
- the session info
-
getName
Description copied from interface:MultiUserSessionPool
Gets the name of this pool.- Specified by:
getName
in interfaceMultiUserSessionPool
- Returns:
- the name
-
getMaxSize
public int getMaxSize()Description copied from interface:MultiUserSessionPool
Gets the maximum pool size per session info.- Specified by:
getMaxSize
in interfaceMultiUserSessionPool
- 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 interfaceMultiUserSessionPool
- 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 interfaceMultiUserSessionPool
- 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 interfaceMultiUserSessionPool
-
isShutdown
public boolean isShutdown()Description copied from interface:MultiUserSessionPool
Returns whether the pool is shutdown.- Specified by:
isShutdown
in interfaceMultiUserSessionPool
- Returns:
- true if shutdown
-
determineSessionCloned
Determines whether the next session to open should be cloned or not.- Parameters:
sessionInfo
- the session info requestedpool
- the session pool for the given session info- Returns:
- true to be cloned
-
isPooledDbRemovable
Determines whether the given pooled session can be removed from the pool due to timeout.
This method is provided to override the default inDbPool
, which is used a private subclass inMultiUserDbPool
.- Parameters:
pooledDb
- the pooled session- Returns:
- true if it can be removed
-