io.dropwizard.db.DataSourceFactory Java Examples

The following examples show how to use io.dropwizard.db.DataSourceFactory. 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: DbDiffCommand.java    From dropwizard-experiment with MIT License 7 votes vote down vote up
@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
    // The existing database with migrations managed by Liquibase.
    DataSourceFactory outdatedDb = configuration.getDatabaseConfig();

    try (CloseableLiquibase outdatedLiquibase = createLiquibase(outdatedDb)) {
        // A temporary database that starts out empty and then gets the autogenerated Ebean table definitions applied.
        DataSourceFactory freshDb = EbeanConfigUtils.clone(outdatedDb);
        String url = outdatedDb.getUrl();
        freshDb.setUrl(url.substring(0, url.lastIndexOf("/")) + "/migrationdiff");

        // Creating the Ebean server makes it apply its table definitions to the database immediately.
        ServerConfig serverConfig = EbeanConfigUtils.createServerConfig(freshDb);
        serverConfig.setDdlGenerate(true);
        serverConfig.setDdlRun(true);
        EbeanServer ebeanServer = EbeanServerFactory.create(serverConfig);

        try (CloseableLiquibase freshLiquibase = createLiquibase(freshDb)) {
            // Create and print the differences between the two databases, i.e. a migration that should be applied to update to the newest Ebean definitions.
            DiffResult diff = outdatedLiquibase.diff(freshLiquibase.getDatabase(), outdatedLiquibase.getDatabase(), CompareControl.STANDARD);
            DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diff, new DiffOutputControl(false, false, true));
            diffToChangeLog.print(System.out);
        }
    }
}
 
Example #2
Source File: JDBIOptionalLocalDateTest.java    From dropwizard-java8 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: EbeanBundle.java    From dropwizard-experiment with MIT License 6 votes vote down vote up
private static void applyMigrations(DataSourceFactory dbConfig, MetricRegistry metrics) throws Exception {
    Stopwatch migrationsTimer = Stopwatch.createStarted();

    // Borrowed from AbstractLiquibaseCommand.
    DataSourceFactory lbConfig = EbeanConfigUtils.clone(dbConfig);
    lbConfig.setMaxSize(1);
    lbConfig.setMinSize(1);
    lbConfig.setInitialSize(1);

    try (CloseableLiquibase liquibase = new CloseableLiquibase(dbConfig.build(metrics, "liquibase"))) {
        log.info("Checking for database migrations.");
        liquibase.update("");

        migrationsTimer.stop();
        metrics.timer(MetricRegistry.name(EbeanBundle.class, "migrations")).update(migrationsTimer.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS);
        log.info("Database migrations complete in {} ms.", migrationsTimer.elapsed(TimeUnit.MILLISECONDS));
    } catch (ValidationFailedException e) {
        e.printDescriptiveError(System.err);
        throw e;
    }
}
 
Example #4
Source File: TodoListApplication.java    From dropwizard-experiment with MIT License 6 votes vote down vote up
@Override
public void initialize(Bootstrap<TodoListConfiguration> bootstrap) {
    ebeanBundle = new EbeanBundle();
    //rabbitMqBundle = new RabbitMQBundle();

    // This outputs xDateTimes as ISO strings rather than an array of numbers in JSON.
    bootstrap.getObjectMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

    bootstrap.addBundle(new Java8Bundle());
    bootstrap.addBundle(ebeanBundle);
    //bootstrap.addBundle(rabbitMqBundle);
    bootstrap.addBundle(new OAuth2Bundle(ebeanBundle));
    bootstrap.addBundle(new TodoClientBundle());
    bootstrap.addBundle(new MigrationsBundle<TodoListConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(TodoListConfiguration configuration) {
            return configuration.getDatabaseConfig();
        }
    });

    // The anonymous subclass seems to be needed for the config type to be picked up correctly.
    bootstrap.addCommand(new WorkersCommand<TodoListConfiguration>(TodoListApplication.this) {});
    bootstrap.addCommand(new DbDiffCommand<TodoListConfiguration>() {});
}
 
Example #5
Source File: JooqBundleTest.java    From droptools with Apache License 2.0 6 votes vote down vote up
@Test
public void providesADefaultJooqFactoryName() throws Exception {
    jooqBundle = new JooqBundle<DropwizardConfig>() {
        @Override
        public JooqFactory getJooqFactory(DropwizardConfig configuration) {
            return jooqFactory;
        }

        @Override
        public DataSourceFactory getDataSourceFactory(DropwizardConfig configuration) {
            return dataSourceFactoryPrimary;
        }
    };
    jooqBundle.run(new DropwizardConfig(), environment);
    assertThat(jooqBundle.getConfigurationMap().containsKey(DEFAULT_NAME));
}
 
Example #6
Source File: UpgradeCommand.java    From irontest with Apache License 2.0 6 votes vote down vote up
@Override
public void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception {
    String ironTestHome = namespace.getString("IronTestHome");
    IronTestConfiguration configuration = getIronTestConfiguration(ironTestHome);
    DataSourceFactory systemDBConfiguration = configuration.getSystemDatabase();
    String fullyQualifiedSystemDBURL = getFullyQualifiedSystemDBURL(ironTestHome, systemDBConfiguration.getUrl());
    DefaultArtifactVersion systemDBVersion = getSystemDBVersionStr(fullyQualifiedSystemDBURL, systemDBConfiguration.getUser(),
            systemDBConfiguration.getPassword());
    DefaultArtifactVersion jarFileVersion = new DefaultArtifactVersion(Version.VERSION);

    int comparison = systemDBVersion.compareTo(jarFileVersion);
    if ("SNAPSHOT".equals(systemDBVersion.getQualifier())) {
        System.out.println("System database version " + systemDBVersion + " is a SNAPSHOT version. Upgrade is not supported.");
    } else if ("SNAPSHOT".equals(jarFileVersion.getQualifier())) {
        System.out.println("Jar file version " + jarFileVersion + " is a SNAPSHOT version. Upgrade is not supported.");
    } else if (comparison == 0) {
        System.out.println("System database and the jar file are of the same version, so no need to upgrade.");
    } else if (comparison > 0) {    //  system database version is bigger than the jar file version
        System.out.printf(IronTestConstants.PROMPT_TEXT_WHEN_SYSTEM_DB_VERSION_IS_BIGGER_THAN_JAR_VERSION,
                systemDBVersion, jarFileVersion);
    } else {    //  system database version is smaller than the jar file version
        UpgradeActions upgradeActions = new UpgradeActions();
        upgradeActions.upgrade(systemDBVersion, jarFileVersion, ironTestHome, fullyQualifiedSystemDBURL,
                systemDBConfiguration.getUser(), systemDBConfiguration.getPassword());
    }
}
 
Example #7
Source File: ReaperApplication.java    From cassandra-reaper with Apache License 2.0 6 votes vote down vote up
private void initDatabase(ReaperApplicationConfiguration config) throws ReaperException {
  Flyway flyway = new Flyway();
  DataSourceFactory dsfactory = config.getDataSourceFactory();
  flyway.setDataSource(
      dsfactory.getUrl(),
      dsfactory.getUser(),
      dsfactory.getPassword());

  if ("database".equals(config.getStorageType())) {
    LOG.warn("!!!!!!!!!!    USAGE 'database' AS STORAGE TYPE IS NOW DEPRECATED   !!!!!!!!!!!!!!");
    LOG.warn("!!!!!!!!!!    PLEASE USE EITHER 'postgres' OR 'h2' FROM NOW ON     !!!!!!!!!!!!!!");
    if (config.getDataSourceFactory().getUrl().contains("h2")) {
      flyway.setLocations("/db/h2");
    } else {
      flyway.setLocations("/db/postgres");
    }
  } else {
    flyway.setLocations("/db/".concat(config.getStorageType().toLowerCase()));
  }
  flyway.setBaselineOnMigrate(true);
  flyway.repair();
  flyway.migrate();
}
 
Example #8
Source File: ReaperApplicationConfigurationTest.java    From cassandra-reaper with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  //create a valid config
  DataSourceFactory dataSourceFactory = new DataSourceFactory();
  dataSourceFactory.setDriverClass("org.postgresql.Driver");
  dataSourceFactory.setUrl("jdbc:postgresql://db.example.com/db-prod");
  dataSourceFactory.setUser("user");
  CassandraFactory cassandraFactory = new CassandraFactory();
  cassandraFactory.setContactPoints(new String[]{"127.0.0.1"});
  config.setCassandraFactory(cassandraFactory);
  config.setPostgresDataSourceFactory(dataSourceFactory);
  config.setHangingRepairTimeoutMins(1);
  config.setRepairParallelism(RepairParallelism.DATACENTER_AWARE);
  config.setRepairRunThreadCount(1);
  config.setSegmentCount(1);
  config.setScheduleDaysBetween(7);
  config.setStorageType("foo");
  config.setIncrementalRepair(false);
  config.setBlacklistTwcsTables(true);
}
 
Example #9
Source File: TestJdbiDynamicAttributes.java    From soabase with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #10
Source File: SQLIngester.java    From macrobase with Apache License 2.0 6 votes vote down vote up
private void initializeConnection() throws SQLException {
    if (connection == null) {
        DataSourceFactory factory = new DataSourceFactory();

        factory.setDriverClass(getDriverClass());
        factory.setUrl(String.format("%s//%s/%s", getJDBCUrlPrefix(), dbUrl, dbName));
        factory.setProperties(getJDBCProperties());

        if (dbUser != null) {
            factory.setUser(this.dbUser);
        }
        if (dbPassword != null) {
            factory.setPassword(dbPassword);
        }

        source = factory.build(MacroBase.metrics, dbName);
        this.connection = source.getConnection();
    }
}
 
Example #11
Source File: JDBIOptionalInstantTest.java    From dropwizard-java8 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #12
Source File: JDBIOptionalLocalDateTimeTest.java    From dropwizard-java8 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #13
Source File: Quartz.java    From dropwizard-experiment with MIT License 5 votes vote down vote up
@Inject
public Quartz(QuartzConfiguration quartzConfig, DataSourceFactory dbConfig, ServiceLocator locator) throws SchedulerException {
    this.quartzConfig = quartzConfig;
    this.dbConfig = dbConfig;

    SchedulerFactory schedulerFactory = new StdSchedulerFactory(getProperties());
    scheduler = schedulerFactory.getScheduler();
    scheduler.setJobFactory(new HK2JobFactory(locator));

    scheduler.start();
}
 
Example #14
Source File: EbeanConfigUtils.java    From dropwizard-experiment with MIT License 5 votes vote down vote up
public static DataSourceFactory clone(DataSourceFactory dbConfig) {
    DataSourceFactory newConfig = new DataSourceFactory();
    newConfig.setUser(dbConfig.getUser());
    newConfig.setPassword(dbConfig.getPassword());
    newConfig.setUrl(dbConfig.getUrl());
    newConfig.setDriverClass(dbConfig.getDriverClass());
    newConfig.setMaxSize(dbConfig.getMaxSize());
    newConfig.setMinSize(dbConfig.getMinSize());
    newConfig.setInitialSize(dbConfig.getInitialSize());

    return newConfig;
}
 
Example #15
Source File: TrellisApplication.java    From trellis with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(final Bootstrap<AppConfiguration> bootstrap) {
    super.initialize(bootstrap);
    bootstrap.addBundle(new MigrationsBundle<AppConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(final AppConfiguration config) {
            return config.getDataSourceFactory();
        }
        @Override
        public String getMigrationsFileName() {
            return "org/trellisldp/jdbc/migrations.yml";
        }
    });
}
 
Example #16
Source File: EbeanConfigUtils.java    From dropwizard-experiment with MIT License 5 votes vote down vote up
public static ServerConfig createServerConfig(DataSourceFactory dbConfig) {
    ServerConfig config = new ServerConfig();
    config.setName("main");
    config.setDataSourceConfig(createDataSourceConfig(dbConfig));
    config.setDefaultServer(true);

    EbeanEntities.getEntities().forEach(config::addClass);

    return config;
}
 
Example #17
Source File: RufusApplication.java    From rufus with MIT License 5 votes vote down vote up
@Override
public void initialize(Bootstrap<RufusConfiguration> bootstrap) {
    bootstrap.addBundle(new AssetsBundle("/app", "/", "index.html"));
    bootstrap.addBundle(new ViewBundle<>());
    bootstrap.addBundle(new MultiPartBundle());
    bootstrap.addBundle(new MigrationsBundle<RufusConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(RufusConfiguration conf) {
            return conf.getDataSourceFactory();
        }
    });
}
 
Example #18
Source File: SingularityTestModule.java    From Singularity with Apache License 2.0 5 votes vote down vote up
private DataSourceFactory getDataSourceFactory() {
  DataSourceFactory dataSourceFactory = new DataSourceFactory();
  dataSourceFactory.setDriverClass("org.h2.Driver");
  dataSourceFactory.setUrl("jdbc:h2:mem:singularity;DB_CLOSE_DELAY=-1");
  dataSourceFactory.setUser("user");
  dataSourceFactory.setPassword("password");

  return dataSourceFactory;
}
 
Example #19
Source File: NiPingMonitorApplication.java    From SAPNetworkMonitor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<ServerConfiguration> bootstrap) {

    bootstrap.addBundle(new MigrationsBundle<ServerConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(ServerConfiguration configuration) {
            return configuration.getDataSourceFactory();
        }
    });

    bootstrap.addBundle(new AssetsBundle("/com/cloudwise/sap/niping/view/static", "/static", null, "static"));
    bootstrap.addBundle(new AssetsBundle("/com/cloudwise/sap/niping/view/vendor", "/vendor", null, "vendor"));
    bootstrap.addBundle(new ViewBundle<ServerConfiguration>());
}
 
Example #20
Source File: SingularityDbModule.java    From Singularity with Apache License 2.0 5 votes vote down vote up
private static boolean driverConfigured(
  Optional<DataSourceFactory> dataSourceFactoryOptional,
  String jdbcDriverclass
) {
  return (
    dataSourceFactoryOptional != null &&
    dataSourceFactoryOptional.isPresent() &&
    jdbcDriverclass.equals(dataSourceFactoryOptional.get().getDriverClass())
  );
}
 
Example #21
Source File: AbstractServiceIntegrationTests.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@BeforeAll
static void beforeAll() throws Exception {
    DataSourceFactory dbConfig = new DataSourceFactory();
    dbConfig.setDriverClass(Driver.class.getName());
    dbConfig.setUrl("jdbc:h2:mem:./" + URIEL_JDBC_SUFFIX);
    dbConfig.setProperties(ImmutableMap.<String, String>builder()
            .put(DIALECT, H2Dialect.class.getName())
            .put(HBM2DDL_AUTO, "create")
            .put(GENERATE_STATISTICS, "false")
            .build());

    baseDataDir = Files.createTempDirectory("uriel");

    UrielApplicationConfiguration config = new UrielApplicationConfiguration(
            dbConfig,
            WebSecurityConfiguration.DEFAULT,
            new UrielConfiguration.Builder()
                    .baseDataDir(baseDataDir.toString())
                    .jophielConfig(JophielClientConfiguration.DEFAULT)
                    .sandalphonConfig(SandalphonClientConfiguration.DEFAULT)
                    .sealtielConfig(SealtielClientConfiguration.DEFAULT)
                    .gabrielConfig(GabrielClientConfiguration.DEFAULT)
                    .submissionConfig(SubmissionConfiguration.DEFAULT)
                    .fileConfig(FileConfiguration.DEFAULT)
                    .build());

    support = new DropwizardTestSupport<>(UrielApplication.class, config);
    support.before();
}
 
Example #22
Source File: KeywhizConfig.java    From keywhiz with Apache License 2.0 5 votes vote down vote up
/**
 * Customizes the database config when requested. If the username for the database is not set, the
 * current user is set as the username.
 *
 * @return DatabaseConfiguration for read/write database.
 */
public DataSourceFactory getDataSourceFactory() {
  if (database.getUser() == null) {
    database.setUser(USER_NAME.value());
  }
  return database;
}
 
Example #23
Source File: KeywhizConfig.java    From keywhiz with Apache License 2.0 5 votes vote down vote up
/**
 * Customizes the database config when requested. If the username for the database is not set, the
 * current user is set as the username.
 *
 * @return DatabaseConfiguration for readonly database.
 */
public DataSourceFactory getReadonlyDataSourceFactory() {
  if (readonlyDatabase.getUser() == null) {
    readonlyDatabase.setUser(USER_NAME.value());
  }
  return readonlyDatabase;
}
 
Example #24
Source File: ServiceModule.java    From keywhiz with Apache License 2.0 5 votes vote down vote up
@Provides @Singleton @Readonly ManagedDataSource readonlyDataSource(Environment environment,
    KeywhizConfig config) {
  DataSourceFactory dataSourceFactory = config.getReadonlyDataSourceFactory();
  ManagedDataSource dataSource = dataSourceFactory.build(environment.metrics(), "db-readonly");
  environment.lifecycle().manage(dataSource);

  environment.healthChecks().register("db-readonly-health",
      new JooqHealthCheck(dataSource, RETURN_UNHEALTHY));

  return dataSource;
}
 
Example #25
Source File: JooqBundleTest.java    From droptools with Apache License 2.0 5 votes vote down vote up
@Test
public void providesADefaultJooqFactory() throws Exception {
    JooqFactory jooqFactory = new JooqBundle<DropwizardConfig>() {
        @Override
        public DataSourceFactory getDataSourceFactory(DropwizardConfig configuration) {
            return dataSourceFactoryPrimary;
        }
    }.getJooqFactory(new DropwizardConfig());

    assertThat(jooqFactory).isNotNull();
}
 
Example #26
Source File: JerahmeelApplicationConfiguration.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
public JerahmeelApplicationConfiguration(
        @JsonProperty("database") DataSourceFactory databaseConfig,
        @JsonProperty("webSecurity") WebSecurityConfiguration webSecurityConfig,
        @JsonProperty("jerahmeel") JerahmeelConfiguration jerahmeelConfig) {

    this.databaseConfig = databaseConfig;
    this.webSecurityConfig = webSecurityConfig;
    this.jerahmeelConfig = jerahmeelConfig;
}
 
Example #27
Source File: DatabaseModule.java    From monasca-common with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
  bind(DataSourceFactory.class).toInstance(config);
  bind(DBI.class).toProvider(new Provider<DBI>() {
    @Override
    public DBI get() {
      try {
        return new DBIFactory().build(environment, config, "platform");
      } catch (ClassNotFoundException e) {
        throw new ProvisionException("Failed to provision DBI", e);
      }
    }
  }).in(Scopes.SINGLETON);
}
 
Example #28
Source File: AbstractServiceIntegrationTests.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@BeforeAll
static void beforeAll() throws Exception {
    DataSourceFactory dbConfig = new DataSourceFactory();
    dbConfig.setDriverClass(Driver.class.getName());
    dbConfig.setUrl("jdbc:h2:mem:./" + JERAHMEEL_JDBC_SUFFIX);
    dbConfig.setProperties(ImmutableMap.<String, String>builder()
            .put(DIALECT, H2Dialect.class.getName())
            .put(HBM2DDL_AUTO, "create")
            .put(GENERATE_STATISTICS, "false")
            .build());

    baseDataDir = Files.createTempDirectory("jerahmeel");

    JerahmeelApplicationConfiguration config = new JerahmeelApplicationConfiguration(
            dbConfig,
            WebSecurityConfiguration.DEFAULT,
            new JerahmeelConfiguration.Builder()
                    .baseDataDir(baseDataDir.toString())
                    .jophielConfig(JophielClientConfiguration.DEFAULT)
                    .sandalphonConfig(SandalphonClientConfiguration.DEFAULT)
                    .gabrielConfig(GabrielClientConfiguration.DEFAULT)
                    .submissionConfig(SubmissionConfiguration.DEFAULT)
                    .build());

    support = new DropwizardTestSupport<>(JerahmeelApplication.class, config);
    support.before();
}
 
Example #29
Source File: JophielApplicationConfiguration.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
public JophielApplicationConfiguration(
        @JsonProperty("database") DataSourceFactory databaseConfig,
        @JsonProperty("webSecurity") WebSecurityConfiguration webSecurityConfig,
        @JsonProperty("jophiel") JophielConfiguration jophielConfig) {

    this.databaseConfig = databaseConfig;
    this.webSecurityConfig = webSecurityConfig;
    this.jophielConfig = jophielConfig;
}
 
Example #30
Source File: EbeanConfigUtils.java    From dropwizard-experiment with MIT License 5 votes vote down vote up
public static DataSourceConfig createDataSourceConfig(DataSourceFactory dbConfig) {
    DataSourceConfig config = new DataSourceConfig();
    config.setUsername(dbConfig.getUser());
    config.setPassword(dbConfig.getPassword());
    config.setUrl(dbConfig.getUrl());
    config.setDriver(dbConfig.getDriverClass());
    config.setMinConnections(dbConfig.getMinSize());
    config.setMaxConnections(dbConfig.getMaxSize());

    return config;
}