io.dropwizard.jdbi3.JdbiFactory Java Examples

The following examples show how to use io.dropwizard.jdbi3.JdbiFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IronTestApplication.java    From irontest with Apache License 2.0 6 votes vote down vote up
private void createSampleResources(IronTestConfiguration configuration, Environment environment) {
    final JdbiFactory jdbiFactory = new JdbiFactory();
    final Jdbi jdbi = jdbiFactory.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)));
}
 
Example #2
Source File: TrellisServiceBundler.java    From trellis with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new application service bundler.
 * @param config the application configuration
 * @param environment the dropwizard environment
 */
public TrellisServiceBundler(final AppConfiguration config, final Environment environment) {
    // Use a database connection
    final Jdbi jdbi = new JdbiFactory().build(environment, config.getDataSourceFactory(), "trellis");

    auditService = new DefaultAuditService();
    timemapGenerator = new DefaultTimemapGenerator();
    constraintServices = new DefaultConstraintServices(singletonList(new LdpConstraintService()));
    mementoService = buildMementoService(config, jdbi);
    resourceService = buildResourceService(config, environment, jdbi);
    binaryService = buildBinaryService(config);
    ioService = buildIoService(config, jdbi);
    eventService = AppUtils.getNotificationService(config.getNotifications(), environment);
}
 
Example #3
Source File: IronTestApplication.java    From irontest with Apache License 2.0 5 votes vote down vote up
@Override
public void run(IronTestConfiguration configuration, Environment environment) throws IOException {
    final JdbiFactory jdbiFactory = new JdbiFactory();
    final Jdbi systemDBJdbi = jdbiFactory.build(environment, configuration.getSystemDatabase(), "systemDatabase");

    if (!checkVersion(systemDBJdbi)) {
        System.out.println("Press Enter to exit.");
        System.in.read();
        System.exit(0);
    }

    //  Override Java's trusted cacerts with our own trust store if available.
    //  Notice that setting the properties without the trust store being existing could cause unexpected result
    //  at runtime with Java 10 (Java 1.8 does not have the issue), such as failure of SOAP test step run (caused
    //  by 'new SSLContextBuilder().loadTrustMaterial').
    if (new File(configuration.getSslTrustStorePath()).exists()) {
        System.setProperty("javax.net.ssl.trustStore", configuration.getSslTrustStorePath());
        System.setProperty("javax.net.ssl.trustStorePassword", configuration.getSslTrustStorePassword());
    }

    //  start WireMock server (in the same JVM)
    WireMockServer wireMockServer = new WireMockServer(options()
            .extensions(new ResponseTemplateTransformer(true))
            .port(Integer.parseInt(configuration.getWireMock().get("port")))
            .maxRequestJournalEntries(Integer.parseInt(configuration.getWireMock().get("maxRequestJournalEntries")))
            .notifier(new WireMockFileNotifier())
    );
    wireMockServer.start();

    createSystemResources(configuration, environment, systemDBJdbi, wireMockServer);
    createSampleResources(configuration, environment);
}
 
Example #4
Source File: ServerApplication.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private Jdbi createJdbi(final AppConfig configuration, final Environment environment) {
  final JdbiFactory factory = new JdbiFactory();
  final Jdbi jdbi =
      factory.build(environment, configuration.getDatabase(), "postgresql-connection-pool");
  JdbiDatabase.registerRowMappers(jdbi);

  if (configuration.isLogSqlStatements()) {
    JdbiDatabase.registerSqlLogger(jdbi);
  }
  return jdbi;
}
 
Example #5
Source File: HelloJDBIService.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void run(HelloWorldConfiguration config, Environment environment) {
    final JdbiFactory factory = new JdbiFactory();
    final Jdbi jdbi = factory.build(environment, config.getDatabaseConfiguration(), "RDBMS");
	
    // Test type 1: JSON serialization and Test type 6: Plaintext are tested against HelloWorldService class
    environment.jersey().register(new WorldResource(new WorldRepository(jdbi))); // Test types 2, 3 & 5: Single database query, Multiple database queries & Database updates
    environment.jersey().register(new FortuneResource(new FortuneRepository(jdbi))); // Test type 4: Fortunes
}