Package io.agroal.api
Interface AgroalDataSource
-
- All Superinterfaces:
AutoCloseable
,CommonDataSource
,DataSource
,Serializable
,Wrapper
public interface AgroalDataSource extends AutoCloseable, DataSource, Serializable
Extension of the DataSource interface that exposes some of its internals. The Agroal project is all about providing a good (reliable, fast, easy to use maintain and understand) implementation of this interface. Agroal - the natural database connection pool!- Author:
- Luis Barreiro
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
AgroalDataSource.FlushMode
Modes supported on the flush operation.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
void
flush(AgroalDataSource.FlushMode mode)
Performs a flush action on the connections of the pool.static AgroalDataSource
from(AgroalDataSourceConfiguration configuration, AgroalDataSourceListener... listeners)
Create an AgroalDataSource from configuration.static AgroalDataSource
from(Supplier<AgroalDataSourceConfiguration> configurationSupplier, AgroalDataSourceListener... listeners)
Create an AgroalDataSource from a supplier of the configuration.AgroalDataSourceConfiguration
getConfiguration()
Allows inspection of the configuration.AgroalDataSourceMetrics
getMetrics()
Allows access to metrics.List<AgroalPoolInterceptor>
getPoolInterceptors()
Get the list of pool interceptors.default boolean
isHealthy(boolean newConnection)
Performs a health check.void
setPoolInterceptors(Collection<? extends AgroalPoolInterceptor> interceptors)
Sets pool interceptors.-
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder, getParentLogger
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder, getConnection, getConnection, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
Method Detail
-
from
static AgroalDataSource from(Supplier<AgroalDataSourceConfiguration> configurationSupplier, AgroalDataSourceListener... listeners) throws SQLException
Create an AgroalDataSource from a supplier of the configuration.- Throws:
SQLException
-
from
static AgroalDataSource from(AgroalDataSourceConfiguration configuration, AgroalDataSourceListener... listeners) throws SQLException
Create an AgroalDataSource from configuration.- Throws:
SQLException
-
getConfiguration
AgroalDataSourceConfiguration getConfiguration()
Allows inspection of the configuration. Some properties allow read / write.
-
getMetrics
AgroalDataSourceMetrics getMetrics()
Allows access to metrics. If metrics are not enabled, returns default values.
-
flush
void flush(AgroalDataSource.FlushMode mode)
Performs a flush action on the connections of the pool.
-
setPoolInterceptors
void setPoolInterceptors(Collection<? extends AgroalPoolInterceptor> interceptors)
Sets pool interceptors.
-
getPoolInterceptors
List<AgroalPoolInterceptor> getPoolInterceptors()
Get the list of pool interceptors. Interceptors are sorted from high to low priority.
-
isHealthy
default boolean isHealthy(boolean newConnection) throws SQLException
Performs a health check. The newConnection parameter determines that a new database connection is established for this purpose, otherwise attempts to get a connection from the pool. WARNING: Using a new connection may cause the size of the pool to go over max-size.- Throws:
SQLException
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
-
-