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:
java.io.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.xPool
. ThePool
itself is backed by an instance ofVertx
obtained via theVertxInstance
service. Configuration of thePool
is handled by theSqlClientPoolConfiguration
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 theSessionFactory
is destroyed. For cases where the underlyingPool
lifecycle is managed externally to Hibernate, useExternalSqlClientPool
.- See Also:
SqlClientPoolConfiguration
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultSqlClientPool()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(java.util.Map configuration)
protected io.vertx.sqlclient.Pool
createPool(java.net.URI uri)
Create a newPool
for the given JDBC URL or database URI, using theVertxInstance
service to obtain an instance ofVertx
, and theSqlClientPoolConfiguration
service to obtain options for creating the connection pool instances.protected io.vertx.sqlclient.Pool
createPool(java.net.URI uri, io.vertx.sqlclient.SqlConnectOptions connectOptions, io.vertx.sqlclient.PoolOptions poolOptions, io.vertx.core.Vertx vertx)
Create a newPool
for the given JDBC URL or database URI, connection pool options, and the given instance ofVertx
.java.util.concurrent.CompletionStage<java.lang.Void>
getCloseFuture()
The shutdown of the pool is actually asynchronous but the core service registry won't return theCompletionStage
.protected io.vertx.sqlclient.Pool
getPool()
org.hibernate.engine.jdbc.spi.SqlExceptionHelper
getSqlExceptionHelper()
protected org.hibernate.engine.jdbc.spi.SqlStatementLogger
getSqlStatementLogger()
void
injectServices(org.hibernate.service.spi.ServiceRegistryImplementor serviceRegistry)
protected java.net.URI
jdbcUrl(java.util.Map<?,?> configurationValues)
Determine the JDBC URL or database URI from the given configuration.static java.net.URI
parse(java.lang.String url)
void
start()
void
stop()
-
Methods inherited from class org.hibernate.reactive.pool.impl.SqlClientPool
getConnection, getConnection, getConnection, getConnection, getTenantPool
-
-
-
-
Method Detail
-
injectServices
public void injectServices(org.hibernate.service.spi.ServiceRegistryImplementor serviceRegistry)
- Specified by:
injectServices
in interfaceorg.hibernate.service.spi.ServiceRegistryAwareService
-
configure
public void configure(java.util.Map configuration)
- Specified by:
configure
in interfaceorg.hibernate.service.spi.Configurable
-
start
public void start()
- Specified by:
start
in interfaceorg.hibernate.service.spi.Startable
-
getCloseFuture
public java.util.concurrent.CompletionStage<java.lang.Void> getCloseFuture()
Description copied from interface:ReactiveConnectionPool
The 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:
getCloseFuture
in interfaceReactiveConnectionPool
-
getPool
protected io.vertx.sqlclient.Pool getPool()
- Specified by:
getPool
in classSqlClientPool
- Returns:
- the underlying Vert.x
Pool
for the current context.
-
getSqlStatementLogger
protected org.hibernate.engine.jdbc.spi.SqlStatementLogger getSqlStatementLogger()
- Specified by:
getSqlStatementLogger
in classSqlClientPool
- Returns:
- a Hibernate
SqlStatementLogger
for logging SQL statements as they are executed
-
getSqlExceptionHelper
public org.hibernate.engine.jdbc.spi.SqlExceptionHelper getSqlExceptionHelper()
- Specified by:
getSqlExceptionHelper
in classSqlClientPool
- Returns:
- a Hibernate
SqlExceptionHelper
for converting exceptions
-
createPool
protected io.vertx.sqlclient.Pool createPool(java.net.URI uri)
Create a newPool
for the given JDBC URL or database URI, using theVertxInstance
service to obtain an instance ofVertx
, and theSqlClientPoolConfiguration
service 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(java.net.URI uri, io.vertx.sqlclient.SqlConnectOptions connectOptions, io.vertx.sqlclient.PoolOptions poolOptions, io.vertx.core.Vertx vertx)
Create a newPool
for 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 ofVertx
to be used by the pool- Returns:
- the new
Pool
-
jdbcUrl
protected java.net.URI jdbcUrl(java.util.Map<?,?> configurationValues)
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:
stop
in interfaceorg.hibernate.service.spi.Stoppable
-
parse
public static java.net.URI parse(java.lang.String url)
-
-