Package com.kheops.jmap.db
Class DatabaseNamedConnectionPool
java.lang.Object
com.kheops.util.KObjectPool
com.kheops.jmap.db.DatabaseConnectionPool
com.kheops.jmap.db.DatabaseNamedConnectionPool
- All Implemented Interfaces:
JMapServerSessionListener,KSchedulerClient
public class DatabaseNamedConnectionPool
extends DatabaseConnectionPool
implements JMapServerSessionListener
-
Field Summary
Fields inherited from class com.kheops.jmap.db.DatabaseConnectionPool
currentSchema, databaseConfig, listeners, poolInfoFields inherited from class com.kheops.util.KObjectPool
cleanupPeriod, recyclePeriod, shrinkTime, TIMEOUT_UNDEFINED, TIMEOUT_UNLIMITED -
Constructor Summary
ConstructorsConstructorDescriptionDatabaseNamedConnectionPool(JMapServerSessionCtrl sessionCtrl) Creates a new DatabaseNamedConnectionPool instance.DatabaseNamedConnectionPool(JMapServerSessionCtrl connCtrl, DatabaseConnectionPoolInfo poolInfo) Deprecated.DatabaseNamedConnectionPool(JMapServerSessionCtrl connCtrl, DatabaseConnectionPoolInfo poolInfo, DatabaseConfig config) Deprecated.use the default constructor andinit(DatabaseConnectionPoolInfo, DatabaseConfig) -
Method Summary
Modifier and TypeMethodDescriptionBorrows a connection from the main connection pool.borrowConnection(int id) Borrows a connection from the pool for exclusive use until it is returned by calling the methodreturnConnection.voidclose()This method closes one by one all the objects currently opened for this the poolvoidShould not be called.This method gets the PoolMonitorInfo associated with the KObject pool instance.booleaninit(DatabaseConnectionPoolInfo poolInfo, DatabaseConfig databaseConfig) Initializes the connection pool with the specified pool info.voidinitialize(int minimumSize, long shrinkTime, long cleanupPeriod, long recyclePeriod) Initializes a KObjectPool instance with the specified minimum size, recycle period, clean up period and shrink periodvoidreturnConnection(int id, Connection conn) Returns a connection to the poll that was obtained using the methodborrowConnection.voidreturnConnection(Connection conn) Returns the specified connection to the main connection pool.voidschCallback(int jobId) This method is automatically called by the KScheduler to either perform the clean up or object recycle jobsvoidvoidMethods inherited from class com.kheops.jmap.db.DatabaseConnectionPool
activate, addListener, borrowConnection, create, deactivate, getCurrentSchema, getDatabaseConfig, getDatabaseConnectionPoolInfo, getId, getLastException, getStatus, getSystemDefaultTimeout, internalErrorOccurred, isInactive, removeListener, reset, setDatabaseConfig, setStatus, validateMethods inherited from class com.kheops.util.KObjectPool
apply, checkIn, checkOut, checkOut, createUnlockedInstance, getDefaultTimeout, getPoolMaximumSize, getPoolSize, getPoolUsageCount, getPoolUsagePeak, initialize, initialize, resourceAdded, setDefaultTimeout, setPoolMaximumSize, setPoolMinimumSize
-
Constructor Details
-
DatabaseNamedConnectionPool
Creates a new DatabaseNamedConnectionPool instance.- Parameters:
sessionCtrl- a valid JMapServerSessionCtrl instance.- Since:
- 6.5
- See Also:
-
DatabaseNamedConnectionPool
@Deprecated public DatabaseNamedConnectionPool(JMapServerSessionCtrl connCtrl, DatabaseConnectionPoolInfo poolInfo) Deprecated.use theDatabaseNamedConnectionPool(JMapServerSessionCtrl)constructor andinit(DatabaseConnectionPoolInfo, DatabaseConfig)Creates a new connection pool instance.- Parameters:
poolInfo- the DatabaseConnectionPoolInfo instance associated with this DatabaseconnectionPoolsessionCtrl- a valid JMapServerSessionCtrl instance.
-
DatabaseNamedConnectionPool
@Deprecated public DatabaseNamedConnectionPool(JMapServerSessionCtrl connCtrl, DatabaseConnectionPoolInfo poolInfo, DatabaseConfig config) Deprecated.use the default constructor andinit(DatabaseConnectionPoolInfo, DatabaseConfig)Creates a new connection pool instance.- Parameters:
poolInfo- the DatabaseConnectionPoolInfo instance associated with this DatabaseconnectionPoolsessionCtrl- a valid JMapServerSessionCtrl instance.databaseConfig- the database configuration to use with borrowed connections.
-
-
Method Details
-
init
Initializes the connection pool with the specified pool info.- Overrides:
initin classDatabaseConnectionPool- Parameters:
poolInfo- the DatabaseConnectionPoolInfo instance associated with this DatabaseconnectionPooldatabaseConfig- the database configuration to use with borrowed connections.- Returns:
- true if no error occurred during the initialization.
-
initialize
public void initialize(int minimumSize, long shrinkTime, long cleanupPeriod, long recyclePeriod) throws Exception Description copied from class:KObjectPoolInitializes a KObjectPool instance with the specified minimum size, recycle period, clean up period and shrink period- Overrides:
initializein classKObjectPool- Parameters:
minimumSize- the minimum number of objects in this poolshrinkTime- the amount of time extra objects can remain inactive before it eligible for cleanupcleanupPeriod- the amount of time between cleanupsrecyclePeriod- the amount of time an initial object can remain inactive before it is recycled (closed than reopen).- Throws:
Exception- if an error occurred while initializing the object pool
-
schCallback
public void schCallback(int jobId) This method is automatically called by the KScheduler to either perform the clean up or object recycle jobs- Specified by:
schCallbackin interfaceKSchedulerClient- Overrides:
schCallbackin classKObjectPool- Parameters:
jobId- the job Id to determine which job will be done
-
borrowConnection
Borrows a connection from the main connection pool.- Overrides:
borrowConnectionin classDatabaseConnectionPool- Returns:
- a connection from the main connection pool.
- Throws:
SQLException
-
borrowConnection
Borrows a connection from the pool for exclusive use until it is returned by calling the methodreturnConnection.- Overrides:
borrowConnectionin classDatabaseConnectionPool- Parameters:
id- an object which identifies the connection borrower.- Returns:
- a database connection
- Throws:
SQLException
-
returnConnection
Returns the specified connection to the main connection pool.- Overrides:
returnConnectionin classDatabaseConnectionPool- Parameters:
conn- the connection to return.
-
returnConnection
Returns a connection to the poll that was obtained using the methodborrowConnection. This method MUST ABSOLUTELY be called when the connection not needed anymore otherwise it will stay unavailable for ever for other users.- Overrides:
returnConnectionin classDatabaseConnectionPool- Parameters:
id- an integer which identifies the connection borrower.conn- the corresponding connection
-
expire
Should not be called.- Overrides:
expirein classDatabaseConnectionPool- Parameters:
o- object (DatabaseConnectionPool) to close
-
sessionCreated
- Specified by:
sessionCreatedin interfaceJMapServerSessionListener
-
sessionDestroyed
- Specified by:
sessionDestroyedin interfaceJMapServerSessionListener
-
getMonitoringInfo
This method gets the PoolMonitorInfo associated with the KObject pool instance. The PoolMonitorInfo maintains the pool statistics- Overrides:
getMonitoringInfoin classKObjectPool- Returns:
- the corresponding PoolMonitorInfo instance
- See Also:
-
close
public void close()Description copied from class:KObjectPoolThis method closes one by one all the objects currently opened for this the pool- Overrides:
closein classKObjectPool
-
DatabaseNamedConnectionPool(JMapServerSessionCtrl)constructor andinit(DatabaseConnectionPoolInfo, DatabaseConfig)