public class DefaultDbPool extends Object implements SessionPool
The pool can be used with any ConnectionManager.
If used with the DefaultConnectionManager, each Db instance corresponds to a
physical JDBC-connection. If used with an MpxConnectionManager, the Db instances
map to virtual connections that will be attached temporarily during db-operations,
i.e. the PdoCache will retain its data across sessions
(if not closed due to idle timeout).
This is the preferred configuration in server applications with a lot of clients.
In order to clear the PdoCache on db-close, you have to override the closeDb method.
| Constructor and Description |
|---|
DefaultDbPool(ConnectionManager conMgr,
SessionInfo ui)
Creates a pool useful for most servers.
Using the default connection manager. |
DefaultDbPool(String name,
ConnectionManager conMgr,
SessionInfo sessionInfo,
int iniSize,
int incSize,
int minSize,
int maxSize,
long maxIdleMinutes,
long maxUsageMinutes)
Creates a pool.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeDb(Db db)
Closes a db.
The method can be overridden if there is something to do after/before close. |
ConnectionManager |
getConnectionManager()
Gets the connection manager.
|
int |
getIncSize()
Gets the minimum increment to enlarge the pool.
|
int |
getIniSize()
Gets the initial size.
|
long |
getMaxIdleMinutes()
Gets the idle timeout in minutes.
|
int |
getMaxSize() |
long |
getMaxUsageMinutes()
Gets the usage timeout in minutes.
|
int |
getMinSize()
Gets the minimum size.
|
String |
getName()
Gets the name of this pool.
|
Db |
getSession() |
SessionInfo |
getSessionInfo()
Gets the server's session info.
|
int |
getSize() |
boolean |
isShutdown() |
void |
putSession(Session session) |
void |
setIncSize(int incSize)
Sets the minimum increment to enlarge the pool.
|
void |
setMaxIdleMinutes(long maxIdleMinutes)
Sets the idle minutes.
Sessions are closed if unused for given minutes. |
void |
setMaxSize(int maxSize)
Sets the maximum size.
|
void |
setMaxUsageMinutes(long maxUsageMinutes)
Sets the maximum usage minutes.
Sessions are closed if unused and first used foe given timeout. |
void |
setMinSize(int minSize)
Sets the minimum size.
|
void |
shutdown()
Closes all databases in the pool, cleans up and makes the pool unusable.
|
String |
toString()
Gets the pool's name
|
public DefaultDbPool(String name, ConnectionManager conMgr, SessionInfo sessionInfo, int iniSize, int incSize, int minSize, int maxSize, long maxIdleMinutes, long maxUsageMinutes)
name - the name of the poolconMgr - the connection manager to use for new Db instancessessionInfo - the server's session infoiniSize - the initial poolsizeincSize - the number of Db instances to enlarge the pool if all in useminSize - the minimum number of Db instances to keep in poolmaxSize - the maximum number of Db instances, 0 = unlimitedmaxIdleMinutes - the idle timeout in minutes to close unused Db instances, 0 = unlimitedmaxUsageMinutes - the max. used time in minutes, 0 = unlimitedpublic DefaultDbPool(ConnectionManager conMgr, SessionInfo ui)
conMgr - the connection managerui - the userinfo for the created Dbpublic String getName()
getName in interface SessionPoolpublic SessionInfo getSessionInfo()
public ConnectionManager getConnectionManager()
public int getIniSize()
public int getIncSize()
public void setIncSize(int incSize)
incSize - the minimum increment (at least 1)public int getMinSize()
public void setMinSize(int minSize)
minSize - the minimum size (at least 1)public int getMaxSize()
getMaxSize in interface SessionPoolpublic void setMaxSize(int maxSize)
maxSize - the maximum size (at least minSize)public long getMaxIdleMinutes()
public void setMaxIdleMinutes(long maxIdleMinutes)
maxIdleMinutes - the idle timeout, 0 if unlimitedpublic long getMaxUsageMinutes()
public void setMaxUsageMinutes(long maxUsageMinutes)
maxUsageMinutes - the usage timeout, 0 if unlimitedprotected void closeDb(Db db)
db - the Db instance to closepublic void shutdown()
shutdown in interface SessionPoolpublic boolean isShutdown()
isShutdown in interface SessionPoolpublic int getSize()
getSize in interface SessionPoolpublic Db getSession()
getSession in interface SessionProviderpublic void putSession(Session session)
putSession in interface ReturnableSessionProviderCopyright © 2016 Krake Softwaretechnik. All rights reserved.