tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r1354173 - in /tomcat/trunk/modules/jdbc-pool: doc/ src/main/java/org/apache/tomcat/jdbc/pool/ src/main/java/org/apache/tomcat/jdbc/pool/interceptor/ src/test/java/org/apache/tomcat/jdbc/test/
Date Tue, 26 Jun 2012 19:08:30 GMT
Author: fhanik
Date: Tue Jun 26 19:08:27 2012
New Revision: 1354173

URL: http://svn.apache.org/viewvc?rev=1354173&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53445
by allowing
 a) override the getObjectName method of the SlowQueryReportJmx class
 b) specify the objectName=xxx attribute in the configuration


Modified:
    tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
    tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
    tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSource.java
    tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/SlowQueryReportJmx.java
    tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java

Modified: tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml?rev=1354173&r1=1354172&r2=1354173&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Tue Jun 26 19:08:27 2012
@@ -617,6 +617,12 @@
            The default value is <code>true</code>.
         </p>
       </attribute>
+      <attribute name="objectName" required="false">
+        <p>(String) Define a valid <code>javax.management.ObjectName</code>
string that will be used to register this object with the platform mbean server
+           The default value is <code>null</code> and the object will be registered
using 
+           tomcat.jdbc:type=org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx,name=the-name-of-the-pool
+        </p>
+      </attribute>
     </attributes>
   </subsection>
   <subsection name="org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer">

Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java?rev=1354173&r1=1354172&r2=1354173&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
Tue Jun 26 19:08:27 2012
@@ -54,10 +54,15 @@ import org.apache.juli.logging.LogFactor
  */
 
 public class ConnectionPool {
+
+    /**
+     * Default domain for objects registering with an mbean server
+     */
+    public static final String POOL_JMX_DOMAIN = "tomcat.jdbc";
     /**
      * Prefix type for JMX registration
      */
-    public static final String POOL_JMX_TYPE_PREFIX = "tomcat.jdbc:type=";
+    public static final String POOL_JMX_TYPE_PREFIX = POOL_JMX_DOMAIN+":type=";
 
     /**
      * Logger

Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSource.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSource.java?rev=1354173&r1=1354172&r2=1354173&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSource.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSource.java
Tue Jun 26 19:08:27 2012
@@ -113,7 +113,7 @@ public class DataSource extends DataSour
      * @throws MalformedObjectNameException
      */
     public ObjectName createObjectName(ObjectName original) throws MalformedObjectNameException
{
-        String domain = "tomcat.jdbc";
+        String domain = ConnectionPool.POOL_JMX_DOMAIN;
         Hashtable<String,String> properties = original.getKeyPropertyList();
         String origDomain = original.getDomain();
         properties.put("type", "ConnectionPool");

Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/SlowQueryReportJmx.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/SlowQueryReportJmx.java?rev=1354173&r1=1354172&r2=1354173&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/SlowQueryReportJmx.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/SlowQueryReportJmx.java
Tue Jun 26 19:08:27 2012
@@ -58,6 +58,8 @@ public class SlowQueryReportJmx extends 
     public static final String SLOW_QUERY_NOTIFICATION = "SLOW QUERY";
     public static final String FAILED_QUERY_NOTIFICATION = "FAILED QUERY";
 
+    public static final String objectNameAttribute = "objectName";
+
     protected static CompositeType SLOW_QUERY_TYPE;
 
     private static final Log log = LogFactory.getLog(SlowQueryReportJmx.class);
@@ -267,8 +269,13 @@ public class SlowQueryReportJmx extends 
     }
 
 
-    public static ObjectName getObjectName(Class<?> clazz, String poolName) throws
MalformedObjectNameException {
-        ObjectName oname = new ObjectName(ConnectionPool.POOL_JMX_TYPE_PREFIX+clazz.getName()+",name="
+ poolName);
+    public ObjectName getObjectName(Class<?> clazz, String poolName) throws MalformedObjectNameException
{
+        ObjectName oname = null;
+        if (getProperties().containsKey(objectNameAttribute)) {
+            oname = new ObjectName(getProperties().get(objectNameAttribute).getValue());
+        } else {
+            oname = new ObjectName(ConnectionPool.POOL_JMX_TYPE_PREFIX+clazz.getName()+",name="
+ poolName);
+        }
         return oname;
     }
 

Modified: tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java?rev=1354173&r1=1354172&r2=1354173&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java
Tue Jun 26 19:08:27 2012
@@ -102,7 +102,7 @@ public class TestSlowQueryReport extends
         ClientListener listener = new ClientListener();
         ConnectionPool pool = datasource.getPool();
         ManagementFactory.getPlatformMBeanServer().addNotificationListener(
-                SlowQueryReportJmx.getObjectName(SlowQueryReportJmx.class, pool.getName()),
+                new SlowQueryReportJmx().getObjectName(SlowQueryReportJmx.class, pool.getName()),
                 listener,
                 null,
                 null);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message