Project: Tomcat
Bug 53445 Support consistent Jmx object naming strategy across managed resources
Reported: 2012-06-20 19:20:53 | Status: resolved fixed

Tomcat JDBC Pool Versions tested: 7.0.27 & 7.0.28 More of an inquiry. Let me preface by saying we have recently adopted this pool and are very pleased so far. Currently, Jmx managed resources like ConnectionPool and SlowQueryReportJmx are registered under the same domain (i.e. tomcat.jdbc). Some users may want to employ an alternate object naming strategy. With DataSource#createObjectName it is relatively easy to change the ConnectionPool ObjectName (i.e. subclass). However, with SlowQueryReportJmx, due to a static getObjectName method, it requires overriding additional methods which is less desirable. It appears that ConnectionPool has a constant POOL_JMX_TYPE_PREFIX. SlowQueryReportJmx appears to use this but DataSource does not? Is there any reason that the SlowQueryReportJmx#getObjectName method is static? What about registering an object naming strategy with the pool that the various components would use, facilitating consistency? This would mitigate the need to override just to alter the ObjectName. Reference: Spring MBean exporters and their ObjectNamingStrategy interface. Thanks.

Files changed in fix:
modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSource.java modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/SlowQueryReportJmx.java modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java