Permalink
Browse files

Register database pool with JMX

  • Loading branch information...
christianbauer committed Nov 7, 2017
1 parent 3205395 commit a1beca3e6292947a10622fb38b2e9c1401fee0c5
@@ -30,6 +30,8 @@
public interface Database {
String PROPERTY_POOL_NAME = Database.class.getName() + ".POOL_NAME";
/**
* @return Persistence unit properties you want to use for this database (e.g. Hibernate dialect already set), will be passed into {@link #open}.
*/
@@ -58,6 +60,8 @@
@Override
public void open(Map<String, Object> properties, String connectionUrl, String username, String password, int connectionTimeoutSeconds, int minIdle, int maxPoolSize) {
hikariConfig = new HikariConfig();
hikariConfig.setRegisterMbeans(true);
hikariConfig.setPoolName(properties.containsKey(PROPERTY_POOL_NAME)? properties.get(PROPERTY_POOL_NAME).toString() : "or-pool");
hikariConfig.setThreadFactory(new ContainerThreadFactory("Database Connections"));
hikariConfig.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
hikariConfig.addDataSourceProperty("url", connectionUrl);
View
@@ -20,7 +20,7 @@ sqliteVersion = 3.20.0
hibernateVersion = 5.2.12.Final
hibernateValidatorVersion = 5.3.6.Final
postgresJdbcVersion = 9.4.1209
hikaricpVersion = 2.6.3
hikaricpVersion = 2.7.2
junitVersion = 4.12
spockVersion = 1.1-groovy-2.4
objenesisVersion = 2.2

0 comments on commit a1beca3

Please sign in to comment.