Class Jdbi3Builders


  • public class Jdbi3Builders
    extends Object
    Utilities for building Dropwizard-managed Jdbi version 3 instances.

    The Jdbi factory methods in this class will automatically search for and install the appropriate JdbiPlugin when the database is H2 or Postgres. The H2 plugin is org.jdbi.v3.core.h2.H2DatabasePlugin and the Postgres plugin is org.jdbi.v3.postgres.PostgresPlugin.

    The SqlObjectPlugin is always installed, and is assumed to be on the classpath.

    Note also that when installing plugins, JDBI ignores duplicates (e.g. if you attempt to install more than one SqlObjectPlugin) only when the plugin is designed as a "single-install" plugin. JDBI plugins are "single-install" when they extend the package-private JdbiPlugin.Singleton class.

    • Constructor Summary

      Constructors 
      Constructor Description
      Jdbi3Builders()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.jdbi.v3.core.Jdbi buildManagedJdbi​(io.dropwizard.setup.Environment environment, io.dropwizard.db.PooledDataSourceFactory dataSourceFactory, io.dropwizard.db.ManagedDataSource managedDataSource, String healthCheckName, org.jdbi.v3.core.spi.JdbiPlugin... jdbiPlugins)
      Build a Dropwizard-managed Jdbi instance with metrics and health check given an Environment, a PooledDataSourceFactory, a ManagedDataSource, and a name to give the health check.
      static org.jdbi.v3.core.Jdbi buildManagedJdbi​(io.dropwizard.setup.Environment environment, io.dropwizard.db.PooledDataSourceFactory dataSourceFactory, io.dropwizard.db.ManagedDataSource dataSource, org.jdbi.v3.core.spi.JdbiPlugin... jdbiPlugins)
      Build a Dropwizard-managed Jdbi instance with metrics and health check given an Environment, a PooledDataSourceFactory, and a ManagedDataSource.
      static org.jdbi.v3.core.Jdbi buildManagedJdbi​(io.dropwizard.setup.Environment environment, io.dropwizard.db.PooledDataSourceFactory dataSourceFactory, String healthCheckName, org.jdbi.v3.core.spi.JdbiPlugin... jdbiPlugins)
      Build a Dropwizard-managed Jdbi instance with metrics and health check given an Environment, a PooledDataSourceFactory, and a name to give the health check.
      static org.jdbi.v3.core.Jdbi buildManagedJdbi​(io.dropwizard.setup.Environment environment, io.dropwizard.db.PooledDataSourceFactory dataSourceFactory, org.jdbi.v3.core.spi.JdbiPlugin... jdbiPlugins)
      Build a Dropwizard-managed Jdbi instance with metrics and health check given an Environment and PooledDataSourceFactory.
    • Constructor Detail

      • Jdbi3Builders

        public Jdbi3Builders()
    • Method Detail

      • buildManagedJdbi

        public static org.jdbi.v3.core.Jdbi buildManagedJdbi​(io.dropwizard.setup.Environment environment,
                                                             io.dropwizard.db.PooledDataSourceFactory dataSourceFactory,
                                                             org.jdbi.v3.core.spi.JdbiPlugin... jdbiPlugins)
        Build a Dropwizard-managed Jdbi instance with metrics and health check given an Environment and PooledDataSourceFactory. This will also register SqlObjectPlugin with JDBI before returning it.
        Parameters:
        environment - the Environment
        dataSourceFactory - the PooledDataSourceFactory
        jdbiPlugins - any other JdbiPlugin objects desired
        Returns:
        the Jdbi instance
        Implementation Note:
        With the exception of SqlObjectPlugin, this method will allow you to install multiple of the same plugin. User beware.
      • buildManagedJdbi

        public static org.jdbi.v3.core.Jdbi buildManagedJdbi​(io.dropwizard.setup.Environment environment,
                                                             io.dropwizard.db.PooledDataSourceFactory dataSourceFactory,
                                                             String healthCheckName,
                                                             org.jdbi.v3.core.spi.JdbiPlugin... jdbiPlugins)
        Build a Dropwizard-managed Jdbi instance with metrics and health check given an Environment, a PooledDataSourceFactory, and a name to give the health check.
        Parameters:
        environment - the Environment
        dataSourceFactory - the PooledDataSourceFactory
        healthCheckName - the health check's name
        jdbiPlugins - any other JdbiPlugin objects desired
        Returns:
        the Jdbi instance
        Implementation Note:
        With the exception of SqlObjectPlugin, this method will allow you to install multiple of the same plugin. User beware.
      • buildManagedJdbi

        public static org.jdbi.v3.core.Jdbi buildManagedJdbi​(io.dropwizard.setup.Environment environment,
                                                             io.dropwizard.db.PooledDataSourceFactory dataSourceFactory,
                                                             io.dropwizard.db.ManagedDataSource dataSource,
                                                             org.jdbi.v3.core.spi.JdbiPlugin... jdbiPlugins)
        Build a Dropwizard-managed Jdbi instance with metrics and health check given an Environment, a PooledDataSourceFactory, and a ManagedDataSource. This will also register SqlObjectPlugin with JDBI before returning it.
        Parameters:
        environment - the Environment
        dataSourceFactory - the PooledDataSourceFactory
        dataSource - the ManagedDataSource
        jdbiPlugins - any other JdbiPlugin objects desired
        Returns:
        the Jdbi instance
        Implementation Note:
        With the exception of SqlObjectPlugin, this method will allow you to install multiple of the same plugin. User beware.
      • buildManagedJdbi

        public static org.jdbi.v3.core.Jdbi buildManagedJdbi​(io.dropwizard.setup.Environment environment,
                                                             io.dropwizard.db.PooledDataSourceFactory dataSourceFactory,
                                                             io.dropwizard.db.ManagedDataSource managedDataSource,
                                                             String healthCheckName,
                                                             org.jdbi.v3.core.spi.JdbiPlugin... jdbiPlugins)
        Build a Dropwizard-managed Jdbi instance with metrics and health check given an Environment, a PooledDataSourceFactory, a ManagedDataSource, and a name to give the health check. This will also register SqlObjectPlugin with JDBI before returning it.
        Parameters:
        environment - the Environment
        dataSourceFactory - the PooledDataSourceFactory
        managedDataSource - the ManagedDataSource
        healthCheckName - the health check's name
        jdbiPlugins - any other JdbiPlugin objects desired
        Returns:
        the Jdbi instance
        Implementation Note:
        With the exception of SqlObjectPlugin, this method will allow you to install multiple of the same plugin. User beware.