Package org.hibernate.reactive.pool.impl
Class DefaultSqlClientPool
java.lang.Object
org.hibernate.reactive.pool.impl.SqlClientPool
org.hibernate.reactive.pool.impl.DefaultSqlClientPool
- All Implemented Interfaces:
Serializable,ReactiveConnectionPool,org.hibernate.service.Service,org.hibernate.service.spi.Configurable,org.hibernate.service.spi.ServiceRegistryAwareService,org.hibernate.service.spi.Startable,org.hibernate.service.spi.Stoppable
public class DefaultSqlClientPool
extends SqlClientPool
implements org.hibernate.service.spi.ServiceRegistryAwareService, org.hibernate.service.spi.Configurable, org.hibernate.service.spi.Stoppable, org.hibernate.service.spi.Startable
A pool of reactive connections backed by a Vert.x
Pool.
The Pool itself is backed by an instance of Vertx
obtained via the VertxInstance service. Configuration of
the Pool is handled by the SqlClientPoolConfiguration
service.
This class may be extended by programs which wish to implement custom connection management or multitenancy.
The lifecycle of this pool is managed by Hibernate Reactive: it
is created when the reactive SessionFactory
is created and destroyed when the SessionFactory is
destroyed. For cases where the underlying Pool lifecycle
is managed externally to Hibernate, use
ExternalSqlClientPool.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected io.vertx.sqlclient.PoolcreatePool(URI uri) Create a newPoolfor the given JDBC URL or database URI, using theVertxInstanceservice to obtain an instance ofVertx, and theSqlClientPoolConfigurationservice to obtain options for creating the connection pool instances.protected io.vertx.sqlclient.PoolcreatePool(URI uri, io.vertx.sqlclient.SqlConnectOptions connectOptions, io.vertx.sqlclient.PoolOptions poolOptions, io.vertx.core.Vertx vertx) Create a newPoolfor the given JDBC URL or database URI, connection pool options, and the given instance ofVertx.The shutdown of the pool is actually asynchronous but the core service registry won't return theCompletionStage.protected io.vertx.sqlclient.PoolgetPool()org.hibernate.engine.jdbc.spi.SqlExceptionHelperprotected org.hibernate.engine.jdbc.spi.SqlStatementLoggervoidinjectServices(org.hibernate.service.spi.ServiceRegistryImplementor serviceRegistry) protected URIDetermine the JDBC URL or database URI from the given configuration.static URIvoidstart()voidstop()Methods inherited from class org.hibernate.reactive.pool.impl.SqlClientPool
getConnection, getConnection, getConnection, getConnection, getTenantPool, selectJdbcOutsideTransaction
-
Constructor Details
-
DefaultSqlClientPool
public DefaultSqlClientPool()
-
-
Method Details
-
injectServices
public void injectServices(org.hibernate.service.spi.ServiceRegistryImplementor serviceRegistry) - Specified by:
injectServicesin interfaceorg.hibernate.service.spi.ServiceRegistryAwareService
-
configure
- Specified by:
configurein interfaceorg.hibernate.service.spi.Configurable
-
start
public void start()- Specified by:
startin interfaceorg.hibernate.service.spi.Startable
-
getCloseFuture
Description copied from interface:ReactiveConnectionPoolThe shutdown of the pool is actually asynchronous but the core service registry won't return theCompletionStage. If you need to wait for the underlying pool to be closed, after closing the SessionFactory you can get the CompletionStage instance from this getter.- Specified by:
getCloseFuturein interfaceReactiveConnectionPool
-
getPool
protected io.vertx.sqlclient.Pool getPool()- Specified by:
getPoolin classSqlClientPool- Returns:
- the underlying Vert.x
Poolfor the current context.
-
getSqlStatementLogger
protected org.hibernate.engine.jdbc.spi.SqlStatementLogger getSqlStatementLogger()- Specified by:
getSqlStatementLoggerin classSqlClientPool- Returns:
- a Hibernate
SqlStatementLoggerfor logging SQL statements as they are executed
-
getSqlExceptionHelper
public org.hibernate.engine.jdbc.spi.SqlExceptionHelper getSqlExceptionHelper()- Specified by:
getSqlExceptionHelperin classSqlClientPool- Returns:
- a Hibernate
SqlExceptionHelperfor converting exceptions
-
createPool
Create a newPoolfor the given JDBC URL or database URI, using theVertxInstanceservice to obtain an instance ofVertx, and theSqlClientPoolConfigurationservice to obtain options for creating the connection pool instances.- Parameters:
uri- JDBC URL or database URI- Returns:
- the new
Pool
-
createPool
protected io.vertx.sqlclient.Pool createPool(URI uri, io.vertx.sqlclient.SqlConnectOptions connectOptions, io.vertx.sqlclient.PoolOptions poolOptions, io.vertx.core.Vertx vertx) Create a newPoolfor the given JDBC URL or database URI, connection pool options, and the given instance ofVertx.- Parameters:
uri- JDBC URL or database URIconnectOptions- the connection optionspoolOptions- the connection pooling optionsvertx- the instance ofVertxto be used by the pool- Returns:
- the new
Pool
-
jdbcUrl
Determine the JDBC URL or database URI from the given configuration.- Parameters:
configurationValues- the configuration properties- Returns:
- the JDBC URL as a
URI
-
stop
public void stop()- Specified by:
stopin interfaceorg.hibernate.service.spi.Stoppable
-
parse
-