本文整理汇总了Java中io.dropwizard.db.PooledDataSourceFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Java PooledDataSourceFactory.build方法的具体用法?Java PooledDataSourceFactory.build怎么用?Java PooledDataSourceFactory.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.dropwizard.db.PooledDataSourceFactory
的用法示例。
在下文中一共展示了PooledDataSourceFactory.build方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import io.dropwizard.db.PooledDataSourceFactory; //导入方法依赖的package包/类
public Jdbi build(Environment environment,
PooledDataSourceFactory configuration,
String name) {
ManagedDataSource dataSource = configuration.build(environment.metrics(), name);
String validationQuery = configuration.getValidationQuery();
Jdbi jdbi = Jdbi.create(dataSource);
jdbi.setTimingCollector(new InstrumentedTimingCollector(environment.metrics(), nameStrategy));
jdbi.installPlugins();
environment.lifecycle().manage(dataSource);
environment.healthChecks().register(name, new JdbiHealthCheck(
environment.getHealthCheckExecutorService(),
configuration.getValidationQueryTimeout().orElseGet(() -> Duration.seconds(5)),
jdbi, validationQuery));
return jdbi;
}
示例2: initialize
import io.dropwizard.db.PooledDataSourceFactory; //导入方法依赖的package包/类
public void initialize(Environment environment, PooledDataSourceFactory dataSourceFactory, String name) {
dataSource = dataSourceFactory.build(environment.metrics(), name);
bCryptPasswordEncryptor = BCryptPasswordEncryptor.newInstance(12);
environment.lifecycle().manage(dataSource);
environment.healthChecks().register(name,
new DataSourceHealthCheck(environment.getHealthCheckExecutorService(),
dataSourceFactory.getValidationQueryTimeout()
.orElse(Duration.seconds(5)),
dataSource,
dataSourceFactory.getValidationQuery()));
}
示例3: build
import io.dropwizard.db.PooledDataSourceFactory; //导入方法依赖的package包/类
public SessionFactory build(final RemoteCredentialHibernateBundle<?> bundle,
final Environment environment,
final PooledDataSourceFactory dbConfig,
final List<Class<?>> entities,
final String name) {
final ManagedDataSource dataSource = dbConfig.build(environment.metrics(), name);
return this.build(bundle, environment, dbConfig, dataSource, entities);
}
示例4: build
import io.dropwizard.db.PooledDataSourceFactory; //导入方法依赖的package包/类
EntityManagerFactory build(EntityManagerBundle<?> bundle,
Environment environment,
PooledDataSourceFactory dbConfig,
List<Class<?>> entities,
String name) {
final ManagedDataSource dataSource = dbConfig.build(environment.metrics(), name);
return build(bundle, environment, dbConfig, dataSource, entities);
}
示例5: build
import io.dropwizard.db.PooledDataSourceFactory; //导入方法依赖的package包/类
public Configuration build(Environment environment, PooledDataSourceFactory factory, String name) throws ClassNotFoundException {
final Settings settings = buildSettings();
final ManagedDataSource dataSource = factory.build(environment.metrics(), name);
final SQLDialect dialect = determineDialect(factory, dataSource);
final ConnectionProvider connectionProvider = new DataSourceConnectionProvider(dataSource);
final Configuration config = new DefaultConfiguration()
.set(settings)
.set(dialect)
.set(connectionProvider);
environment.lifecycle().manage(dataSource);
return config;
}