[jboss-svn-commits] JBL Code SVN: r29869 - labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Oct 29 10:28:16 EDT 2009


Author: mazz
Date: 2009-10-29 10:28:16 -0400 (Thu, 29 Oct 2009)
New Revision: 29869

Modified:
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit/Submit.java
Log:
refactor the submit request code into a shared method

Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit/Submit.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit/Submit.java	2009-10-29 14:15:18 UTC (rev 29868)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit/Submit.java	2009-10-29 14:28:16 UTC (rev 29869)
@@ -92,14 +92,7 @@
      *             if the request failed
      */
     public String deleteAllRules() throws Exception {
-        Comm comm = new Comm(address, port);
-        try {
-            comm.println("DELETEALL");
-            String results = comm.readResponse();
-            return results;
-        } finally {
-            comm.close();
-        }
+        return submitRequest("DELETEALL\n");
     }
 
     /**
@@ -111,14 +104,7 @@
      *             if the request failed
      */
     public String listAllRules() throws Exception {
-        Comm comm = new Comm(address, port);
-        try {
-            comm.println("LIST");
-            String results = comm.readResponse();
-            return results;
-        } finally {
-            comm.close();
-        }
+        return submitRequest("LIST\n");
     }
 
     /**
@@ -146,14 +132,7 @@
         }
         str.append("ENDBOOT\n");
 
-        Comm comm = new Comm(this.address, this.port);
-        try {
-            comm.print(str.toString());
-            String results = comm.readResponse();
-            return results;
-        } finally {
-            comm.close();
-        }
+        return submitRequest(str.toString());
     }
 
     /**
@@ -181,14 +160,7 @@
         }
         str.append("ENDSYS\n");
 
-        Comm comm = new Comm(this.address, this.port);
-        try {
-            comm.print(str.toString());
-            String results = comm.readResponse();
-            return results;
-        } finally {
-            comm.close();
-        }
+        return submitRequest(str.toString());
     }
 
     /**
@@ -240,14 +212,7 @@
         }
         str.append("ENDLOAD\n");
 
-        Comm comm = new Comm(this.address, this.port);
-        try {
-            comm.print(str.toString());
-            String results = comm.readResponse();
-            return results;
-        } finally {
-            comm.close();
-        }
+        return submitRequest(str.toString());
     }
 
     /**
@@ -301,9 +266,24 @@
         }
         str.append("ENDDELETE\n");
 
+        return submitRequest(str.toString());
+    }
+
+    /**
+     * Submits the generic request string to the Byteman agent for processing.
+     * 
+     * @param request
+     *            the request to submit
+     * 
+     * @return the response that the Byteman agent replied with
+     * 
+     * @throws Exception
+     *             if the request failed
+     */
+    public String submitRequest(String request) throws Exception {
         Comm comm = new Comm(this.address, this.port);
         try {
-            comm.print(str.toString());
+            comm.print(request);
             String results = comm.readResponse();
             return results;
         } finally {



More information about the jboss-svn-commits mailing list