Class 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.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:
    SqlClientPoolConfiguration, Serialized Form
    • 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 new Pool for the given JDBC URL or database URI, using the VertxInstance service to obtain an instance of Vertx, and the SqlClientPoolConfiguration 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 new Pool for the given JDBC URL or database URI, connection pool options, and the given instance of Vertx.
      java.util.concurrent.CompletionStage<java.lang.Void> getCloseFuture()
      The shutdown of the pool is actually asynchronous but the core service registry won't return the CompletionStage.
      protected io.vertx.sqlclient.Pool getPool()  
      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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultSqlClientPool

        public DefaultSqlClientPool()
    • Method Detail

      • injectServices

        public void injectServices​(org.hibernate.service.spi.ServiceRegistryImplementor serviceRegistry)
        Specified by:
        injectServices in interface org.hibernate.service.spi.ServiceRegistryAwareService
      • configure

        public void configure​(java.util.Map configuration)
        Specified by:
        configure in interface org.hibernate.service.spi.Configurable
      • start

        public void start()
        Specified by:
        start in interface org.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 the CompletionStage. 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 interface ReactiveConnectionPool
      • getPool

        protected io.vertx.sqlclient.Pool getPool()
        Specified by:
        getPool in class SqlClientPool
        Returns:
        the underlying Vert.x Pool for the current context.
      • getSqlStatementLogger

        protected org.hibernate.engine.jdbc.spi.SqlStatementLogger getSqlStatementLogger()
        Specified by:
        getSqlStatementLogger in class SqlClientPool
        Returns:
        a Hibernate SqlStatementLogger for logging SQL statements as they are executed
      • createPool

        protected io.vertx.sqlclient.Pool createPool​(java.net.URI uri)
        Create a new Pool for the given JDBC URL or database URI, using the VertxInstance service to obtain an instance of Vertx, and the SqlClientPoolConfiguration 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 new Pool for the given JDBC URL or database URI, connection pool options, and the given instance of Vertx.
        Parameters:
        uri - JDBC URL or database URI
        connectOptions - the connection options
        poolOptions - the connection pooling options
        vertx - the instance of Vertx 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 interface org.hibernate.service.spi.Stoppable
      • parse

        public static java.net.URI parse​(java.lang.String url)