Author: fschumacher
Date: Sun Dec  2 11:16:32 2018
New Revision: 1847974

URL: http://svn.apache.org/viewvc?rev=1847974&view=rev
Log:
Extract code to create BackendListenerClient from a classname

Part of #435 and Bugzilla Id: 62972

Modified:
    
jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java

Modified: 
jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java?rev=1847974&r1=1847973&r2=1847974&view=diff
==============================================================================
--- 
jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java
 (original)
+++ 
jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java
 Sun Dec  2 11:16:32 2018
@@ -169,10 +169,8 @@ public class BackendListenerGui extends
 
             String newClassName = ((String) 
classnameCombo.getSelectedItem()).trim();
             try {
-                BackendListenerClient client = (BackendListenerClient) 
Class.forName(newClassName, true,
-                        
Thread.currentThread().getContextClassLoader()).newInstance();
-                BackendListenerClient oldClient = (BackendListenerClient) 
Class.forName(className, true,
-                        
Thread.currentThread().getContextClassLoader()).newInstance();
+                BackendListenerClient client = 
createBackendListenerClient(newClassName);
+                BackendListenerClient oldClient = 
createBackendListenerClient(className);
 
                 Arguments currArgs = new Arguments();
                 argsPanel.modifyTestElement(currArgs);
@@ -222,6 +220,13 @@ public class BackendListenerGui extends
         }
     }
 
+
+    private BackendListenerClient createBackendListenerClient(String 
newClassName)
+            throws ReflectiveOperationException {
+        return (BackendListenerClient) Class.forName(newClassName, true,
+                
Thread.currentThread().getContextClassLoader()).getDeclaredConstructor().newInstance();
+    }
+
     /**
      * Create a panel containing components allowing the user to provide
      * arguments to be passed to the test class instance.


Reply via email to