当前位置: 首页>>代码示例>>Java>>正文


Java PooledDataSourceFactory类代码示例

本文整理汇总了Java中io.dropwizard.db.PooledDataSourceFactory的典型用法代码示例。如果您正苦于以下问题:Java PooledDataSourceFactory类的具体用法?Java PooledDataSourceFactory怎么用?Java PooledDataSourceFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PooledDataSourceFactory类属于io.dropwizard.db包,在下文中一共展示了PooledDataSourceFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connectToDatasource

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
private IDBI connectToDatasource(ShardInfo shardInfo) {
    PooledDataSourceFactory urlReplacedCopy =
            copyAndReplaceURL(dropwizardDSFactory, shardInfo);

    // we cannot re-register using the same name (dropwizard metrics do not merge on name collision)
    String dbShardName = humanFriendlyShardNamer.nameShard(shardInfo);
    DBI jdbi = dropwizardDbiFactory.build(
            dropwizardEnvironment,
            urlReplacedCopy,
            dbShardName);
    if (DBIInitializer != null) {
        DBIInitializer.initialize(jdbi);
    }
    logger.info("New shard connection created: " + dbShardName);

    return jdbi;
}
 
开发者ID:toasttab,项目名称:jdbishard,代码行数:18,代码来源:JDBIManager.java

示例2: build

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
@Override
public DBI build(Environment environment, PooledDataSourceFactory configuration, ManagedDataSource dataSource, String name) {
    final DBI dbi = super.build(environment, configuration, dataSource, name);

    dbi.registerArgumentFactory(new ValueArgumentFactory(configuration.getDriverClass()));
    dbi.registerArgumentFactory(new OptionArgumentFactory(configuration.getDriverClass()));
    dbi.registerContainerFactory(new OptionContainerFactory());

    // The order of container factories is important, least specific to most specific
    dbi.registerContainerFactory(new SeqContainerFactory());
    dbi.registerContainerFactory(new IndexedSeqContainerFactory());
    dbi.registerContainerFactory(new SetContainerFactory());
    dbi.registerContainerFactory(new TreeContainerFactory());
    dbi.registerContainerFactory(new ListContainerFactory());
    dbi.registerContainerFactory(new ArrayContainerFactory());
    dbi.registerContainerFactory(new QueueContainerFactory());
    dbi.registerContainerFactory(new StreamContainerFactory());
    dbi.registerContainerFactory(new VectorContainerFactory());

    return dbi;
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:22,代码来源:VavrDBIFactory.java

示例3: 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;
}
 
开发者ID:arteam,项目名称:dropwizard-jdbi3,代码行数:18,代码来源:JdbiFactory.java

示例4: build

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
public SessionFactory build(final RemoteCredentialHibernateBundle<?> bundle,
        final Environment environment,
        final PooledDataSourceFactory dbConfig,
        final ManagedDataSource dataSource,
        final List<Class<?>> entities) {
    final ConnectionProvider provider = this.buildConnectionProvider(dataSource,
            dbConfig.getProperties());
    final SessionFactory factory = this.buildSessionFactory(bundle,
            dbConfig,
            provider,
            dbConfig.getProperties(),
            entities);
    final SessionFactoryManager managedFactory = new SessionFactoryManager(factory, dataSource);
    environment.lifecycle().manage(managedFactory);
    return factory;
}
 
开发者ID:mtakaki,项目名称:CredentialStorageService-dw-hibernate,代码行数:17,代码来源:SessionFactoryFactory.java

示例5: init

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
private void init(final ImmutableList<Class<?>> inEntities) {
    String numShardsEnv = System.getProperty("db.shards", "2");
    int numShards = Integer.parseInt(numShardsEnv);
    shardManager = new ShardManager(numShards);
    for (int i = 0; i < numShards; i++) {
        final int finalI = i;
        shardBundles.add(new HibernateBundle<T>(inEntities, new SessionFactoryFactory()) {
            @Override
            protected String name() {
                return String.format("connectionpool-%d", finalI);
            }

            @Override
            public PooledDataSourceFactory getDataSourceFactory(T t) {
                return getConfig(t).getShards().get(finalI);
            }
        });
    }
}
 
开发者ID:santanusinha,项目名称:dropwizard-db-sharding-bundle,代码行数:20,代码来源:DBShardingBundle.java

示例6: initialize

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
@Override
public void initialize(final Bootstrap<ProductCatalogConfiguration> bootstrap) {
	bootstrap.addBundle(discoveryBundle);
	bootstrap.addBundle(new MigrationsBundle<ProductCatalogConfiguration>() {

		@Override
		public PooledDataSourceFactory getDataSourceFactory(ProductCatalogConfiguration configuration) {
			return configuration.getDataSourceFactory();
		}
	});
	guiceBundle = GuiceBundle.<ProductCatalogConfiguration> newBuilder().addModule(new ProductCatalogModule())
			.enableAutoConfig(getClass().getPackage().getName()).setConfigClass(ProductCatalogConfiguration.class)
			.build(Stage.PRODUCTION);
	bootstrap.addBundle(guiceBundle);
	// Uncomment below to read the yaml file from Jar
	// bootstrap.setConfigurationSourceProvider(new
	// ResourceConfigurationSourceProvider());
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:19,代码来源:ProductCatalogApplication.java

示例7: initialize

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
@Override
public void initialize(final Bootstrap<ProductReviewConfiguration> bootstrap) {
	bootstrap.addBundle(discoveryBundle);
	bootstrap.addBundle(new MigrationsBundle<ProductReviewConfiguration>() {

		@Override
		public PooledDataSourceFactory getDataSourceFactory(ProductReviewConfiguration configuration) {
			return configuration.getDataSourceFactory();
		}
	});
	guiceBundle = GuiceBundle.<ProductReviewConfiguration> newBuilder().addModule(new ProductReviewModule())
			.enableAutoConfig(getClass().getPackage().getName()).setConfigClass(ProductReviewConfiguration.class)
			.build(Stage.PRODUCTION);
	bootstrap.addBundle(guiceBundle);
	// Uncomment below to read the yaml file from Jar
	// bootstrap.setConfigurationSourceProvider(new
	// ResourceConfigurationSourceProvider());
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:19,代码来源:ProductReviewApplication.java

示例8: run

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
@Override
public final void run(T configuration, Environment environment) throws Exception {
    final PooledDataSourceFactory dbConfig = getDataSourceFactory(configuration);

    this.entityManagerFactory = entityManagerFactoryFactory.build(this, environment, dbConfig, entities, name());
    this.entityManagerContext = new EntityManagerContext(entityManagerFactory);
    this.sharedEntityManager = sharedEntityManagerFactory.build(entityManagerContext);

    registerUnitOfWorkListerIfAbsent(environment).registerEntityManagerFactory(name(), entityManagerFactory);
    environment.healthChecks().register(name(),
            new EntityManagerFactoryHealthCheck(
                    environment.getHealthCheckExecutorService(),
                    dbConfig.getValidationQueryTimeout().orElse(Duration.seconds(5)),
                    entityManagerFactory,
                    dbConfig.getValidationQuery()));
}
 
开发者ID:scottescue,项目名称:dropwizard-entitymanager,代码行数:17,代码来源:EntityManagerBundle.java

示例9: testFindEntityClassesFromDirectory

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testFindEntityClassesFromDirectory() {
    String packageWithEntities = "com.scottescue.dropwizard.entitymanager.entity.fake.entities.pckg";
    ScanningEntityManagerBundle bundle = new ScanningEntityManagerBundle(packageWithEntities) {
        @Override
        public void run(Object o, Environment environment) throws Exception {
        }

        @Override
        public PooledDataSourceFactory getDataSourceFactory(Configuration configuration) {
            return null;
        }
    };

    assertThat(bundle.getEntities()).containsOnly(
            FakeEntity1.class,
            DeepFakeEntity.class,
            DeeperFakeEntity.class);
}
 
开发者ID:scottescue,项目名称:dropwizard-entitymanager,代码行数:21,代码来源:ScanningEntityManagerBundleTest.java

示例10: testFindEntityClassesFromMultipleDirectories

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testFindEntityClassesFromMultipleDirectories() {
    String root = "com.scottescue.dropwizard.entitymanager.entity.fake.entities.";

    ScanningEntityManagerBundle bundle = new ScanningEntityManagerBundle(
            root.concat("pckg"), root.concat("pckg2"), root.concat("pckg3")) {
        @Override
        public void run(Object o, Environment environment) throws Exception {
        }

        @Override
        public PooledDataSourceFactory getDataSourceFactory(Configuration configuration) {
            return null;
        }
    };

    assertThat(bundle.getEntities()).containsOnly(
            FakeEntity1.class,
            FakeEntity2.class,
            FakeEntity3.class,
            DeepFakeEntity.class,
            DeeperFakeEntity.class);
}
 
开发者ID:scottescue,项目名称:dropwizard-entitymanager,代码行数:25,代码来源:ScanningEntityManagerBundleTest.java

示例11: build

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
@Override
public DBI build(Environment environment,
                 PooledDataSourceFactory configuration,
                 ManagedDataSource dataSource,
                 String name) {
    final DBI dbi = super.build(environment, configuration, dataSource, name);

    dbi.registerArgumentFactory(new OptionalArgumentFactory(configuration.getDriverClass()));
    dbi.registerContainerFactory(new OptionalContainerFactory());
    dbi.registerArgumentFactory(new LocalDateArgumentFactory());
    dbi.registerArgumentFactory(new OptionalLocalDateArgumentFactory());
    dbi.registerArgumentFactory(new LocalDateTimeArgumentFactory());
    dbi.registerArgumentFactory(new OptionalLocalDateTimeArgumentFactory());
    dbi.registerMapper(new LocalDateMapper());
    dbi.registerMapper(new LocalDateTimeMapper());

    final Optional<TimeZone> tz = Optional.ofNullable(databaseTimeZone().orNull());
    dbi.registerArgumentFactory(new InstantArgumentFactory(tz));
    dbi.registerArgumentFactory(new OptionalInstantArgumentFactory(tz));
    dbi.registerMapper(new InstantMapper(tz));


    return dbi;
}
 
开发者ID:dropwizard,项目名称:dropwizard-java8,代码行数:25,代码来源:DBIFactory.java

示例12: configureDataSourceFactory

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
private void configureDataSourceFactory(
        final C configuration,
        final Environment environment,
        final String name,
        final PooledDataSourceFactory dataSourceFactory
) throws RuntimeException {

    try {
        final JooqFactory jooqFactory = getJooqFactory(configuration);
        final Configuration cfg = jooqFactory.build(environment, dataSourceFactory, name);
        final JooqHealthCheck healthCheck = new JooqHealthCheck(cfg, dataSourceFactory.getValidationQuery());

        environment.healthChecks().register(name, healthCheck);

        jooqFactoryConfigurationMap.put(name, cfg);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:benjamin-bader,项目名称:droptools,代码行数:20,代码来源:JooqBundle.java

示例13: 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()));
}
 
开发者ID:acciente,项目名称:oacc-example-securetodo,代码行数:12,代码来源:AccessControlContextFactory.java

示例14: run

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
@Override
public void run(final BenchConfiguration config,
                final Environment environment) {
    final DBIFactory factory = new DBIFactory();
    final Optional<PooledDataSourceFactory> tomcatFactory = config.getTomcatFactory().map(x -> x);

    config.getHikariFactory().ifPresent(x -> x.setHealthCheckRegistry(environment.healthChecks()));
    final Optional<PooledDataSourceFactory> hikariFactory = config.getHikariFactory().map(x -> x);
    final PooledDataSourceFactory datasource = tomcatFactory.orElse(hikariFactory.orElse(null));
    final DBI jdbi = factory.build(environment, datasource, "postgresql");
    jdbi.registerMapper(new QuestionMapper());
    final QuestionQuery dao = jdbi.onDemand(QuestionQuery.class);
    environment.jersey().register(new QuestionResource(dao));
}
 
开发者ID:nickbabcock,项目名称:dropwizard-hikaricp-benchmark,代码行数:15,代码来源:BenchApplication.java

示例15: copyAndReplaceURL

import io.dropwizard.db.PooledDataSourceFactory; //导入依赖的package包/类
private PooledDataSourceFactory copyAndReplaceURL(
        DataSourceFactory dsFactory,
        ShardInfo shardInfo) {

    DataSourceFactory copy = new CopiedDataSourceFactory(dsFactory);
    copy.setUrl(shardInfo.url());
    return copy;
}
 
开发者ID:toasttab,项目名称:jdbishard,代码行数:9,代码来源:JDBIManager.java


注:本文中的io.dropwizard.db.PooledDataSourceFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。