Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
Fixes readonlyDataSource.
Browse files Browse the repository at this point in the history
  • Loading branch information
alokmenghrajani committed Apr 22, 2015
1 parent 6892bdb commit 2dad56f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions server/src/main/java/keywhiz/ServiceModule.java
Expand Up @@ -122,8 +122,11 @@ public ServiceModule(KeywhizConfig config, Environment environment) {

@Provides @Singleton @Readonly ManagedDataSource readonlyDataSource(Environment environment,
KeywhizConfig config) {
DataSourceFactory dataSourceFactory = config.getDataSourceFactory();
return dataSourceFactory.build(environment.metrics(), "postgres-readonly");
DataSourceFactory dataSourceFactory = config.getReadonlyDataSourceFactory();
ManagedDataSource dataSource = dataSourceFactory.build(environment.metrics(), "postgres-readonly");
environment.lifecycle().manage(dataSource);

return dataSource;
}

// jOOQ
Expand Down Expand Up @@ -182,12 +185,16 @@ public ServiceModule(KeywhizConfig config, Environment environment) {
}

@Provides @Singleton
@Readonly DBI readonlyDbi(DBIFactory factory, Environment environment, KeywhizConfig config,
MapArgumentFactory mapArgumentFactory, @Readonly ManagedDataSource dataSource)
@Readonly DBI readonlyDbi(KeywhizConfig config, MapArgumentFactory mapArgumentFactory,
@Readonly ManagedDataSource dataSource)
throws ClassNotFoundException {
logger.debug("Creating read-only DBI");
DBI dbi = factory.build(environment, config.getReadonlyDataSourceFactory(), dataSource,
"postgres-readonly");
final DBI dbi = new DBI(dataSource);
dbi.registerArgumentFactory(new OptionalArgumentFactory(config.getReadonlyDataSourceFactory().getDriverClass()));
dbi.registerContainerFactory(new OptionalContainerFactory());
dbi.registerArgumentFactory(new LocalDateTimeArgumentFactory());
dbi.registerMapper(new LocalDateTimeMapper());

dbi.registerArgumentFactory(mapArgumentFactory);
return dbi;
}
Expand Down

0 comments on commit 2dad56f

Please sign in to comment.