Skip to content

Commit

Permalink
Register database pool with JMX
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bauer committed Nov 7, 2017
1 parent 3205395 commit a1beca3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Expand Up @@ -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}.
*/
Expand Down Expand Up @@ -58,6 +60,8 @@ public Map<String, Object> createProperties() {
@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);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -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
Expand Down

0 comments on commit a1beca3

Please sign in to comment.