當前位置: 首頁>>代碼示例>>Java>>正文


Java DBI.onDemand方法代碼示例

本文整理匯總了Java中org.skife.jdbi.v2.DBI.onDemand方法的典型用法代碼示例。如果您正苦於以下問題:Java DBI.onDemand方法的具體用法?Java DBI.onDemand怎麽用?Java DBI.onDemand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.skife.jdbi.v2.DBI的用法示例。


在下文中一共展示了DBI.onDemand方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import org.skife.jdbi.v2.DBI; //導入方法依賴的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: setupTests

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
@Before
public void setupTests() throws IOException {
    final DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setDriverClass("org.h2.Driver");
    dataSourceFactory.setUrl("jdbc:h2:mem:test-" + System.currentTimeMillis() + "?user=sa");
    dataSourceFactory.setInitialSize(1);
    final DBI dbi = new VavrDBIFactory().build(env, dataSourceFactory, "test");
    try (Handle h = dbi.open()) {
        h.execute("CREATE TABLE tasks (" +
                "id INT PRIMARY KEY, " +
                "assignee VARCHAR(255) NOT NULL, " +
                "start_date TIMESTAMP, " +
                "end_date TIMESTAMP, " +
                "comments VARCHAR(1024) " +
                ")");
    }
    dao = dbi.onDemand(TaskDao.class);

    dao.insert(100, Option.some("Name 1"), LocalDate.parse("2017-08-24"), Option.none(), Option.none());
    dao.insert(200, Option.some("Name 2"), LocalDate.parse("2017-08-25"), Option.none(), Option.some("To be done"));
}
 
開發者ID:dropwizard,項目名稱:dropwizard-vavr,代碼行數:22,代碼來源:VavrDBIFactoryTest.java

示例3: createSampleResources

import org.skife.jdbi.v2.DBI; //導入方法依賴的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

示例4: runService

import org.skife.jdbi.v2.DBI; //導入方法依賴的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

示例5: runService

import org.skife.jdbi.v2.DBI; //導入方法依賴的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

示例6: executeDeleteOnDataSource

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
private void executeDeleteOnDataSource(SqlDropQuarkDataSource node) throws SQLException {
  DBI dbi = getDbi();
  DataSourceDAO dataSourceDAO = dbi.onDemand(DataSourceDAO.class);
  JdbcSourceDAO jdbcDao = dbi.onDemand(JdbcSourceDAO.class);
  QuboleDbSourceDAO quboleDao = dbi.onDemand(QuboleDbSourceDAO.class);
  DataSource jdbcSource = jdbcDao.findByName(node.getIdentifier().getSimple(),
      connection.getDSSet().getId());
  if (jdbcSource != null) {
    jdbcDao.delete(jdbcSource.getId());
    dataSourceDAO.delete(jdbcSource.getId());
  } else {
    DataSource quboleSource = quboleDao.findByName(node.getIdentifier().getSimple(),
        connection.getDSSet().getId());
    if (quboleSource != null) {
      jdbcDao.delete(quboleSource.getId());
      dataSourceDAO.delete(quboleSource.getId());
    }
  }
}
 
開發者ID:qubole,項目名稱:quark,代碼行數:20,代碼來源:QuarkDDLExecutor.java

示例7: run

import org.skife.jdbi.v2.DBI; //導入方法依賴的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

示例8: setupTests

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
@Before
public void setupTests() throws IOException {
    final DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setDriverClass("org.h2.Driver");
    dataSourceFactory.setUrl("jdbc:h2:mem:date-time-optional-" + System.currentTimeMillis() + "?user=sa");
    dataSourceFactory.setInitialSize(1);
    final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test");
    try (Handle h = dbi.open()) {
        h.execute("CREATE TABLE tasks (" +
                "id INT PRIMARY KEY, " +
                "assignee VARCHAR(255) NOT NULL, " +
                "start_date TIMESTAMP, " +
                "end_date TIMESTAMP, " +
                "comments VARCHAR(1024) " +
                ")");
    }
    dao = dbi.onDemand(TaskDao.class);
}
 
開發者ID:dropwizard,項目名稱:dropwizard-java8,代碼行數:19,代碼來源:JDBIOptionalLocalDateTest.java

示例9: run

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
@Override
public void run(final SecureTodoConfiguration configuration,
                final Environment environment) {
   final DBIFactory dbiFactory = new DBIFactory();
   final DBI todoJdbi = dbiFactory.build(environment, configuration.getTodoDbDataSourceFactory(), "todoDb");
   final TodoUserDAO todoUserDao = todoJdbi.onDemand(TodoUserDAO.class);
   final TodoItemDAO todoItemDao = todoJdbi.onDemand(TodoItemDAO.class);

   final AccessControlContextFactory accessControlContextFactory = configuration.getAccessControlContextFactory();
   accessControlContextFactory.initialize(environment, configuration.getOaccDbDataSourceFactory(), "oacc");

   environment.jersey().register(new TodoUserResource(new TodoUserService(todoUserDao, accessControlContextFactory)));
   environment.jersey().register(new TodoItemResource(new TodoItemService(todoItemDao)));

   environment.jersey().register(new AuthDynamicFeature(
         new BasicCredentialAuthFilter.Builder<OaccPrincipal>()
               .setAuthenticator(new OaccBasicAuthenticator(accessControlContextFactory))
               .setRealm("OACC Basic Authentication")
               .buildAuthFilter()));
   // to use @Auth to inject a custom Principal type into a resource:
   environment.jersey().register(new AuthValueFactoryProvider.Binder<>(OaccPrincipal.class));

   environment.jersey().register(new AuthorizationExceptionMapper(environment.metrics()));
   environment.jersey().register(new IllegalArgumentExceptionMapper(environment.metrics()));
   environment.jersey().register(new InvalidCredentialsExceptionMapper(environment.metrics()));
   environment.jersey().register(new NotAuthenticatedExceptionMapper(environment.metrics()));
}
 
開發者ID:acciente,項目名稱:oacc-example-securetodo,代碼行數:28,代碼來源:SecureTodoApplication.java

示例10: run

import org.skife.jdbi.v2.DBI; //導入方法依賴的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

示例11: run

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
@Override
public void run(final TrackerServerConfiguration config,
                final Environment environment) {
    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, config.getDataSourceFactory(), "postgresql");
    final UserDAO dao = jdbi.onDemand(UserDAO.class);
    environment.jersey().register(new MainResource(config, dao));
}
 
開發者ID:Hyphen-ated,項目名稱:trackerserver,代碼行數:9,代碼來源:TrackerServerApplication.java

示例12: apply

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
@Override
public Object apply(Class<?> aClass) {
    DBI dbi = this.dbi;
    if(dbi == null) {
        dbi = injector.getInstance(DBI.class);
    }
    return dbi.onDemand(aClass);
}
 
開發者ID:mlk,項目名稱:jdbi-guice,代碼行數:9,代碼來源:JdbiSuppler.java

示例13: run

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
@Override
public final void run(TileServerConfiguration configuration, Environment environment) {

  final DBIFactory factory = new DBIFactory();
  final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "MySQL");
  final DataDAO dataDao = jdbi.onDemand(DataDAO.class);
  final DataService dataService = new DataService(dataDao);
  environment.jersey().register(new TileResource(dataService));
}
 
開發者ID:gbif,項目名稱:species-population,代碼行數:10,代碼來源:TileServerApplication.java

示例14: JdbiStore

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
public JdbiStore(JdbiConfiguration storeConfiguration,
                 Environment environment,
                 DBI database) {
    super(storeConfiguration, environment);
    database.registerArgumentFactory(new DependencyIdArgumentFactory());
    database.registerArgumentFactory(new ServiceIdArgumentFactory());
    database.registerArgumentFactory(new TenacityConfigurationArgumentFactory(environment.getObjectMapper()));
    database.registerArgumentFactory(new DateTimeArgumentFactory());

    dependencyDB = database.onDemand(DependencyDB.class);
    serviceDB = database.onDemand(ServiceDB.class);

    this.configuration = storeConfiguration;
}
 
開發者ID:guggens,項目名稱:log-dropwizard-eureka-mongo-sample,代碼行數:15,代碼來源:JdbiStore.java

示例15: executeCreateView

import org.skife.jdbi.v2.DBI; //導入方法依賴的package包/類
public int executeCreateView(SqlCreateQuarkView sqlNode) throws SQLException {
  DBI dbi = getDbi();
  List<String> tableNameList = sqlNode.getTableName().names;
  String dataSourceName = tableNameList.get(0);

  ViewDAO viewDAO = dbi.onDemand(ViewDAO.class);

  JdbcSourceDAO jdbcDAO = dbi.onDemand(JdbcSourceDAO.class);
  QuboleDbSourceDAO quboleDAO = dbi.onDemand(QuboleDbSourceDAO.class);
  DataSource dataSource = jdbcDAO.findByName(dataSourceName,
      connection.getDSSet().getId());
  if (dataSource == null) {
    dataSource = quboleDAO.findByName(dataSourceName, connection.getDSSet().getId());
  }

  if (dataSource == null) {
    throw new SQLException("DataSource with name '" + dataSourceName + "' not found");
  }

  SqlPrettyWriter writer = new SqlPrettyWriter(SqlDialect.CALCITE);
  writer.setAlwaysUseParentheses(false);
  writer.setSelectListItemsOnSeparateLines(false);
  writer.setIndentation(0);
  writer.setQuoteAllIdentifiers(true);
  sqlNode.getQuery().unparse(writer, 0, 0);
  final String sql = writer.toString();

  LOG.debug(sql);
  return viewDAO.insert(sqlNode.getName(),
      "No Description", sql,
      0L, dataSource.getId(),
      tableNameList.get(1), tableNameList.get(2),
      connection.getDSSet().getId());
}
 
開發者ID:qubole,項目名稱:quark,代碼行數:35,代碼來源:QuarkDDLExecutor.java


注:本文中的org.skife.jdbi.v2.DBI.onDemand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。