[jboss-svn-commits] JBL Code SVN: r30931 - labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/profiler.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 5 13:05:16 EST 2010


Author: whitingjr
Date: 2010-01-05 13:05:16 -0500 (Tue, 05 Jan 2010)
New Revision: 30931

Modified:
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/profiler/AbstractProfiler.java
Log:
Added support for profiling API using static method calls. No instances needed.


Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/profiler/AbstractProfiler.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/profiler/AbstractProfiler.java	2010-01-05 18:04:07 UTC (rev 30930)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/profiler/AbstractProfiler.java	2010-01-05 18:05:16 UTC (rev 30931)
@@ -31,15 +31,16 @@
 {
    private static final Logger logger = Logger.getLogger(AbstractProfiler.class);
    protected Object profilerInstance;
+   protected Class profilerClass;
    
    protected AbstractProfiler(String fqcn)
    {
       try
       {
-         if (null != fqcn && !StringUtils.equals("", fqcn.trim()))
+         if (null != fqcn && !StringUtils.equals("", fqcn.trim()) && !usesStaticMethods())
          {
-            Class profilerClass = Class.forName(fqcn);
-            profilerInstance = profilerClass.newInstance();
+            this.profilerClass = Class.forName(fqcn);
+            this.profilerInstance = profilerClass.newInstance();
          }
       } 
       catch (ClassNotFoundException cnfe)
@@ -85,11 +86,18 @@
       invoke(getClearMethodName());
    }
    
+   /**
+    * Attempt to invoke the method of the concrete profiling API. Try and handle
+    * static methods.
+    * 
+    * @param name
+    * @throws Exception
+    */
    private void invoke(String name)
       throws Exception
    {
-      Method profilerMethod = getInstance().getClass().getMethod(name); 
-      profilerMethod.invoke(getInstance());
+      Method profilerMethod = this.profilerClass.getMethod(name); 
+      profilerMethod.invoke(getInstance()); // static methods ignore the instance reference
    }
 
    protected Object getInstance()
@@ -102,4 +110,6 @@
    protected abstract String getSuspendMethodName();
    protected abstract String getShutDownMethodName();
    protected abstract String getClearMethodName();
+   
+   protected abstract boolean usesStaticMethods();
 }



More information about the jboss-svn-commits mailing list