java.lang.Object
is.codion.common.db.pool.AbstractConnectionPoolWrapper<T>
- Type Parameters:
T- the type representing the actual pool object
- All Implemented Interfaces:
ConnectionPoolWrapper
public abstract class AbstractConnectionPoolWrapper<T>
extends Object
implements ConnectionPoolWrapper
A default base implementation of the ConnectionPool wrapper, handling the collection of statistics
-
Field Summary
Fields inherited from interface is.codion.common.db.pool.ConnectionPoolWrapper
DEFAULT_IDLE_TIMEOUT, DEFAULT_MAXIMUM_POOL_SIZE, DEFAULT_MINIMUM_POOL_SIZE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConnectionPoolWrapper(ConnectionFactory connectionFactory, is.codion.common.user.User user, DataSource poolDataSource) Instantiates a new AbstractConnectionPool instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract intfinal Connectionconnection(is.codion.common.user.User user) Fetches a connection from the pool.protected abstract ConnectionFetches a connection from the underlying pool.protected final TgetPool()protected abstract intinUse()final booleanfinal booleanfinal DataSourcefinal voidResets the collected usage statisticsfinal voidsetCollectCheckOutTimes(boolean collectCheckOutTimes) Specifies whether to collect connection check out times.final voidsetCollectSnapshotStatistics(boolean collectSnapshotStatistics) Specifies whether to collect usage statistics for a snapshot.protected final voidfinal ConnectionPoolStatisticsstatistics(long since) Retrives usage statistics for the connection pool since timesince.final is.codion.common.user.Useruser()protected abstract intwaiting()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface is.codion.common.db.pool.ConnectionPoolWrapper
close, getCleanupInterval, getIdleConnectionTimeout, getMaximumCheckOutTime, getMaximumPoolSize, getMinimumPoolSize, setCleanupInterval, setIdleConnectionTimeout, setMaximumCheckOutTime, setMaximumPoolSize, setMinimumPoolSize
-
Constructor Details
-
AbstractConnectionPoolWrapper
protected AbstractConnectionPoolWrapper(ConnectionFactory connectionFactory, is.codion.common.user.User user, DataSource poolDataSource) Instantiates a new AbstractConnectionPool instance.- Parameters:
connectionFactory- the connection factoryuser- the connection pool userpoolDataSource- the DataSource
-
-
Method Details
-
user
public final is.codion.common.user.User user()- Specified by:
userin interfaceConnectionPoolWrapper- Returns:
- the user this connection pool is based on.
-
poolDataSource
- Specified by:
poolDataSourcein interfaceConnectionPoolWrapper- Returns:
- the DataSource used by this connection pool
-
connection
Description copied from interface:ConnectionPoolWrapperFetches a connection from the pool. Close the connection to return it to the pool.- Specified by:
connectionin interfaceConnectionPoolWrapper- Parameters:
user- the user credentials- Returns:
- a database connection retrieved from the pool
- Throws:
DatabaseException- in case of an exception while fetching the connection- See Also:
-
resetStatistics
public final void resetStatistics()Description copied from interface:ConnectionPoolWrapperResets the collected usage statistics- Specified by:
resetStatisticsin interfaceConnectionPoolWrapper
-
isCollectSnapshotStatistics
public final boolean isCollectSnapshotStatistics()- Specified by:
isCollectSnapshotStatisticsin interfaceConnectionPoolWrapper- Returns:
- true if pool usage statistics for a snapshot should be collected.
- See Also:
-
setCollectSnapshotStatistics
public final void setCollectSnapshotStatistics(boolean collectSnapshotStatistics) Description copied from interface:ConnectionPoolWrapperSpecifies whether to collect usage statistics for a snapshot.- Specified by:
setCollectSnapshotStatisticsin interfaceConnectionPoolWrapper- Parameters:
collectSnapshotStatistics- the value- See Also:
-
isCollectCheckOutTimes
public final boolean isCollectCheckOutTimes()- Specified by:
isCollectCheckOutTimesin interfaceConnectionPoolWrapper- Returns:
- true if connection check out times should be collected.
- See Also:
-
setCollectCheckOutTimes
public final void setCollectCheckOutTimes(boolean collectCheckOutTimes) Description copied from interface:ConnectionPoolWrapperSpecifies whether to collect connection check out times.- Specified by:
setCollectCheckOutTimesin interfaceConnectionPoolWrapper- Parameters:
collectCheckOutTimes- the value- See Also:
-
statistics
Description copied from interface:ConnectionPoolWrapperRetrives usage statistics for the connection pool since timesince.- Specified by:
statisticsin interfaceConnectionPoolWrapper- Parameters:
since- the time from which statistics should be retrieved- Returns:
- connection pool usage statistics
-
fetchConnection
Fetches a connection from the underlying pool.- Returns:
- a connection from the underlying pool
- Throws:
SQLException- in case of an exception.
-
setPool
- Parameters:
pool- the underlying connection pool
-
getPool
- Returns:
- the underlying pool object
-
available
protected abstract int available()- Returns:
- the number of available connections in this pool
-
inUse
protected abstract int inUse()- Returns:
- the number of connections in active use
-
waiting
protected abstract int waiting()- Returns:
- the number of waiting connection requests
-