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


Java DBIFactory类代码示例

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


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

示例1: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void run(final BloopServerConfiguration configuration,
                final Environment environment) {
    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "postgresql");
    final FlagDAO flagDAO = jdbi.onDemand(FlagDAO.class);
    final NearbyFlagDAO nearbyFlagDAO = jdbi.onDemand(NearbyFlagDAO.class);
    final PlayerDAO playerDAO = jdbi.onDemand(PlayerDAO.class);
    
    final Client client = new JerseyClientBuilder(environment).using(configuration.getJerseyClientConfiguration())
            .build(getName());
    final String firebaseKey = configuration.getFirebaseKey();
    
    environment.jersey().register(new FlagResource(flagDAO, nearbyFlagDAO, playerDAO, client, firebaseKey));
    environment.jersey().register(new PlayerResource(playerDAO, flagDAO));
}
 
开发者ID:BloopApp,项目名称:BloopServer,代码行数:17,代码来源:BloopServerApplication.java

示例2: setup

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception
{
    DBIFactory factory = new DBIFactory();
    Environment environment = new Environment("test", new ObjectMapper(), null, new MetricRegistry(), ClassLoader.getSystemClassLoader());
    DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setUrl("jdbc:hsqldb:mem:soa-jdbi;shutdown=true");
    dataSourceFactory.setDriverClass("org.hsqldb.jdbc.JDBCDriver");
    dataSourceFactory.setLogValidationErrors(true);
    dataSourceFactory.setUser("SA");
    dataSourceFactory.setValidationQuery("SELECT * FROM INFORMATION_SCHEMA.SYSTEM_TABLES");
    DBI jdbi = factory.build(environment, dataSourceFactory, "test");
    dynamicAttributes = new JdbiDynamicAttributes(jdbi, Collections.singletonList("test"));

    dynamicAttributes.getDao().createTable();
    dynamicAttributes.start();
}
 
开发者ID:soabase,项目名称:soabase,代码行数:18,代码来源:TestJdbiDynamicAttributes.java

示例3: JDBIManager

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
/**
 * @param shardService Your shard service.
 * @param shardRegistry Your shard registry.
 * @param dbiRegistry Your DBI registry.
 * @param daoRegistry Your DAO registry.
 * @param dropwizardDbiFactory Your dropwizard application's DBI Factory.
 * @param dropwizardEnvironment Your dropwizard application's environment.
 * @param dropwizardDSFactory Your dropwizard application's datasource factory.
 * @param DBIInitializer We call your initializer immediately after dropwizardDbiFactory builds your
 *                        DBI. @see jdbishard.jdbi.NoOpDBIInitializer.
 * @param humanFriendlyShardNamer We register metrics for each shard connection given the human
 *                                friendly name. @see jdbishard.sharding.IdOnlyShardNamer.
 */
@Inject
public JDBIManager(
        ShardService<ShardIdT, KeyT> shardService,
        ShardRegistry<ShardIdT, KeyT> shardRegistry,
        DBIRegistry<ShardIdT> dbiRegistry,
        DAORegistry<ShardIdT> daoRegistry,
        DBIFactory dropwizardDbiFactory,
        Environment dropwizardEnvironment,
        DataSourceFactory dropwizardDSFactory,
        DBIInitializer DBIInitializer,
        HumanFriendlyShardNamer humanFriendlyShardNamer)
{
    this.shardService = shardService;
    this.shardRegistry = shardRegistry;
    this.dbiRegistry = dbiRegistry;
    this.daoRegistry = daoRegistry;
    this.dropwizardDbiFactory = dropwizardDbiFactory;
    this.dropwizardEnvironment = dropwizardEnvironment;
    this.dropwizardDSFactory = dropwizardDSFactory;
    this.DBIInitializer = DBIInitializer;
    this.humanFriendlyShardNamer = humanFriendlyShardNamer;
}
 
开发者ID:toasttab,项目名称:jdbishard,代码行数:36,代码来源:JDBIManager.java

示例4: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void run(TestAppConfig configuration, Environment environment) throws Exception {

    final ShardRegistry<String, UUID> shardRegistry = new ShardRegistry<>();
    final DAORegistry<String> daoRegistry = new DAORegistry<>();
    final DBIFactory dbiFactory = new DBIFactory();

    jdbiManager = new JDBIManager<>(
            new StaticShardService(),
            shardRegistry,
            new DBIRegistry<>(),
            daoRegistry,
            dbiFactory,
            environment,
            configuration.getDataSourceFactory(),
            new NoOpDBIInitializer(),
            new IdOnlyShardNamer());

    clientDAO = new ClientDAO(shardRegistry, daoRegistry);

    daoRegistry.registerType(ClientShardDAO.class);

    jdbiManager.updateObjects();
}
 
开发者ID:toasttab,项目名称:jdbishard,代码行数:25,代码来源:TestApp.java

示例5: createSampleResources

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
private void createSampleResources(IronTestConfiguration configuration, Environment environment) {
    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getSampleDatabase(), "sampleDatabase");

    //  create DAO objects
    final ArticleDAO articleDAO = jdbi.onDemand(ArticleDAO.class);

    //  create database tables
    articleDAO.createTableIfNotExists();

    //  register APIs
    environment.jersey().register(new ArticleResource(articleDAO));

    //  register SOAP web services
    jaxWsBundle.publishEndpoint(new EndpointBuilder("/article", new ArticleSOAP(articleDAO)));
}
 
开发者ID:zheng-wang,项目名称:irontest,代码行数:17,代码来源:IronTestApplication.java

示例6: initializeStorage

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
private IStorage initializeStorage(ReaperApplicationConfiguration config, Environment environment)
    throws ReaperException {
  IStorage storage;

  if ("memory".equalsIgnoreCase(config.getStorageType())) {
    storage = new MemoryStorage();
  } else if ("cassandra".equalsIgnoreCase(config.getStorageType())) {
    storage = new CassandraStorage(config, environment);
  } else if ("postgres".equalsIgnoreCase(config.getStorageType())
      || "h2".equalsIgnoreCase(config.getStorageType())
      || "database".equalsIgnoreCase(config.getStorageType())) {
    // create DBI instance
    final DBIFactory factory = new DBIFactory();

    // instanciate store
    storage = new PostgresStorage(factory.build(environment, config.getDataSourceFactory(), "postgresql"));
    initDatabase(config);
  } else {
    LOG.error("invalid storageType: {}", config.getStorageType());
    throw new ReaperException("invalid storage type: " + config.getStorageType());
  }
  Preconditions.checkState(storage.isStorageConnected(), "Failed to connect storage");
  return storage;
}
 
开发者ID:thelastpickle,项目名称:cassandra-reaper,代码行数:25,代码来源:ReaperApplication.java

示例7: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void run(PublicAuthConfiguration conf, Environment environment) throws Exception {
    DataSourceFactory dataSourceFactory = conf.getDataSourceFactory();

    jdbi = new DBIFactory().build(environment, dataSourceFactory, "postgresql");
    initialiseMetrics(conf, environment);

    TokenService tokenService = new TokenService(conf.getTokensConfiguration());

    environment.jersey().register(new AuthDynamicFeature(
            new OAuthCredentialAuthFilter.Builder<Token>()
                    .setAuthenticator(new TokenAuthenticator(tokenService))
                    .setPrefix("Bearer")
                    .buildAuthFilter()));
    environment.jersey().register(new AuthValueFactoryProvider.Binder<>(Token.class));

    environment.jersey().register(new PublicAuthResource(new AuthTokenDao(jdbi), tokenService));
    environment.jersey().register(new HealthCheckResource(environment));
    environment.jersey().register(new ValidationExceptionMapper());
    environment.jersey().register(new TokenNotFoundExceptionMapper());
    environment.healthChecks().register("database", new DatabaseHealthCheck(conf,environment));

    environment.servlets().addFilter("LoggingFilter", new LoggingFilter())
            .addMappingForUrlPatterns(of(REQUEST), true, "/v1" + "/*");
}
 
开发者ID:alphagov,项目名称:pay-publicauth,代码行数:26,代码来源:PublicAuthApp.java

示例8: runService

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void runService(final HmlJdbiConfiguration configuration, final Environment environment) throws Exception {
    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "mysql");
    final HmlDao hmlDao = jdbi.onDemand(HmlDao.class);

    Injector injector = Guice.createInjector(new JdbiHmlServiceModule(), new AbstractModule() {
            @Override
            protected void configure() {
                bind(HmlDao.class).toInstance(hmlDao);
            }
        });

    environment.healthChecks().register("database", new DBIHealthCheck(jdbi, "select 1"));

    environment.jersey().register(injector.getInstance(HmlResource.class));
    environment.jersey().register(new HmlExceptionMapper());
    environment.jersey().register(new HmlMessageBodyReader());

    environment.getObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
}
 
开发者ID:nmdp-bioinformatics,项目名称:service-hml,代码行数:22,代码来源:HmlJdbiApplication.java

示例9: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void run(final ServiceRegistryConfiguration configuration, final Environment environment) throws Exception {
    final DataSourceFactory database = configuration.getDatabase();

    // execute DB migrations
    final Flyway flyway = new Flyway();
    flyway.setDataSource(database.getUrl(), database.getUser(), database.getPassword());
    log.debug("execute database migrations");
    flyway.migrate();
    log.info("database migrations successfully executed");

    // create DBI instance
    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, database, "postgresql");

    environment.jersey().register(AuthFactory.binder(new BasicAuthFactory<>(
                    new ServiceRegistryAuthenticator(configuration.getCredentials()), "Realm", ServiceRegistryCaller.class))
    );
    environment.jersey().register(new ServiceResource(jdbi.onDemand(ServiceDAO.class)));
}
 
开发者ID:bitionaire,项目名称:el-bombillo,代码行数:21,代码来源:ServiceRegistryApplication.java

示例10: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void run(SentimentalConfiguration configuration, Environment environment) {
	final TemplateHealthCheck healthCheck = new TemplateHealthCheck(configuration.getTemplate());
	environment.healthChecks().register("template", healthCheck);

	// SPI Lexicon
	final Lexicon lexicon = new FileBasedLexicon(configuration.getLexiconFileName());

	// SPI Trend
	final DBIFactory factory = new DBIFactory();
	final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "postgresql");
	final AuditDAO auditDao = jdbi.onDemand(AuditDAO.class);
	final Trend audit = new TrendRepository(auditDao);

	// Domain Model
	final SentimentAnalysis service = new SentimentAnalysis(lexicon, audit);

	// API RESTful
	final SentimentalResource resource = new SentimentalResource(service);
	environment.jersey().register(resource);

	// API Twitter
	final TwitterAdapter twitterAdapter = new TwitterAdapter(service, new SamplePlayer());
	twitterAdapter.subscribe("devoxx, #memepasmal, @cyriux, @tpierrain, arolla");
	// start
}
 
开发者ID:cyriux,项目名称:hexagonal-sentimental,代码行数:27,代码来源:SentimentalApplication.java

示例11: runService

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void runService(final FeatureJdbiConfiguration configuration, final Environment environment) throws Exception {
    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "mysql");
    final FeatureDao featureDao = jdbi.onDemand(FeatureDao.class);

    Injector injector = Guice.createInjector(new JdbiFeatureServiceModule(), new ExceptionMapperModule(),
        new AbstractModule() {
            @Override
            protected void configure() {
                bind(FeatureDao.class).toInstance(featureDao);
            }
        });

    environment.healthChecks().register("database", new DBIHealthCheck(jdbi, "select 1"));

    environment.jersey().register(injector.getInstance(FeatureResource.class));
    environment.jersey().register(injector.getInstance(UserInputExceptionMapper.class));

    environment.getObjectMapper()
        .enable(SerializationFeature.INDENT_OUTPUT)
        .addMixInAnnotations(Feature.class, FeatureMixIn.class);
}
 
开发者ID:nmdp-bioinformatics,项目名称:service-feature,代码行数:24,代码来源:FeatureJdbiApplication.java

示例12: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
public void run(MyApplicationConfiguration configuration,
                Environment environment) throws ClassNotFoundException {

    // create database connection using JDBI
    final DBIFactory factory = new DBIFactory();
    final DataSourceFactory dataSourceFactory = configuration.getDataSourceFactory();
    final DBI jdbi = factory.build(environment, dataSourceFactory, "derby");

    // add resources
    final UserDAO dao = jdbi.onDemand(UserDAO.class);
    try {
        dao.createUserTable();
        logger.info("User table created");
    } catch (Exception e) {
        // probably the table already exists. Don't worry about it.
        if (e.getCause().getMessage().contains("already exists in Schema")) {
            logger.info("User table already exists.");
        } else {
            logger.log(Level.INFO, "User DB was not created", e);
        }

    }
    environment.jersey().register(new UserResourceImpl(dao));

}
 
开发者ID:echinthaka,项目名称:dropwizard-jdbi-template,代码行数:26,代码来源:MyApplication.java

示例13: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void run(HelloConfiguration configuration, Environment environment) throws ClassNotFoundException {
    final DBI dbi = new DBIFactory().build(environment, configuration.getDataSourceFactory(), "h2");
    final NameDAO nameDAO = dbi.onDemand(NameDAO.class);
    final ObjectGraph objectGraph = ObjectGraph.create(new HelloModule(configuration, nameDAO));

    initializeDatabase(dbi);
    /*
    * API:
    * GET -> String    /hello
    * GET -> String    /hello?name={name}
    * GET -> JSON      /hello/all
    * GET -> JSON      /hello/{id}
    * POST -> JSON     /hello/add
    */
    environment.jersey().register(objectGraph.get(NameResource.class));
}
 
开发者ID:akullpp,项目名称:DGH2,代码行数:18,代码来源:HelloApplication.java

示例14: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
public void run(ThmmyRssConfiguration configuration, Environment env)
        throws Exception {
    client = new JerseyClientBuilder(env).using(configuration.getJerseyClientConfiguration()).using(env)
            .withProperty("PROPERTY_CHUNKED_ENCODING_SIZE", 0).build("jersey-client");
    DBIFactory factory = new DBIFactory();
    DBI jdbi = factory.build(env, configuration.getDatabase(), "announcement-db");
    announcementDAO = jdbi.onDemand(AnnouncementDAO.class);

    tryCreateAnnouncementTable();
    AnnouncementFetcher announcementFetcher = new AnnouncementFetcher(client, configuration);
    env.healthChecks().register("announcement-fetcher-health", new AnnouncementFetcherHealthCheck(configuration, announcementFetcher));
    this.announcementService = new AnnouncementServiceImpl(announcementDAO, announcementFetcher, configuration);
    env.jersey().register(new FeedResource(announcementService, configuration));
    env.jersey().register(new IndexResource(configuration));
}
 
开发者ID:spapageo,项目名称:ethmmyrss,代码行数:17,代码来源:ThmmyRssApplication.java

示例15: run

import io.dropwizard.jdbi.DBIFactory; //导入依赖的package包/类
@Override
protected void run(Environment env, Namespace namespace, T configuration) throws Exception {
    CliConveniences.quietLogging("ifar", "hsqldb.db");

    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(env, getSkidRoadReadOnlyConfiguration(configuration).getDatabaseConfiguration(), "logfile");
    JDBILogFileDAO dao = jdbi.onDemand(DefaultJDBILogFileDAO.class);
    List<CountByState> counts = dao.countLogFilesByState();
    if (!counts.isEmpty()) {
        System.out.println(String.format("%-20s | %-10s", "STATE", "COUNT"));
        System.out.println(String.format("%s_|_%s", StringUtils.repeat("_", 20), StringUtils.repeat("_", 10)));
    }
    for (CountByState cbs : counts) {
        System.out.println(String.format("%-20s | %-10d", cbs.getState(), cbs.getCount()));
    }
}
 
开发者ID:Multifarious,项目名称:skid-road,代码行数:17,代码来源:ListStatesCommand.java


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