minimise move events
[org.ibex.core.git] / src / org / ibex / XMLRPC.java
index 6c1699c..607d34e 100644 (file)
@@ -31,9 +31,15 @@ import org.bouncycastle.util.encoders.Base64;
  */
 class XMLRPC extends JS {
 
-    public XMLRPC(String url, String method) { this(url, method, new HTTP(url)); }
-    public XMLRPC(String url, String method, HTTP http) { this.http = http; this.url = url; this.method = method; }
-    public Object get(Object name) { return new XMLRPC(url, (method.equals("") ? "" : method + ".") + name.toString(), http); }
+    public XMLRPC(String url, String method) {
+        this.http = url.startsWith("stdio:") ? HTTP.stdio : new HTTP(url);
+        this.url = url;
+        this.method = method;
+    }
+    public XMLRPC(String url, String method, XMLRPC httpSource) {
+        this.http = httpSource.http; this.url = url; this.method = method; }
+    public Object get(Object name) {
+        return new XMLRPC(url, (method.equals("") ? "" : method + ".") + name.toString(), this); }
 
 
     /** this holds character content as we read it in -- since there is only one per instance, we don't support mixed content */
@@ -165,9 +171,9 @@ class XMLRPC extends JS {
         content.append("\r\n");
         content.append("<?xml version=\"1.0\"?>\n");
         content.append("    <methodCall>\n");
-        content.append("        <method>");
+        content.append("        <methodName>");
         content.append(method);
-        content.append("</method>\n");
+        content.append("</methodName>\n");
         content.append("        <params>\n");
         for(int i=0; i<args.length(); i++) {
             content.append("            <param>\n");
@@ -313,30 +319,30 @@ class XMLRPC extends JS {
 
     final void call(final JS.UnpauseCallback callback, final JSArray args) {
         try {
-            if (Log.verbose) Log.info(this, "call to " + url + " : " + method);
+            if (Log.rpc) Log.info(this, "call to " + url + " : " + method);
             if (tracker == null) tracker = new Hash();
             if (objects == null) objects = new Vec();
             String request = buildRequest(args);
-            if (Log.verbose) Log.info(this, "send:\n" + request);
+            if (Log.rpc) Log.info(this, "send:\n" + request);
             InputStream is = http.POST("text/xml", request);
             BufferedReader br = new BufferedReader(new InputStreamReader(is));
             try {
                 new Helper().parse(br);
                 final Object result = fault ? new JSExn(objects.elementAt(0)) : objects.size() == 0 ? null : objects.elementAt(0);
-                Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(result); }});
+                Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { callback.unpause(result); }});
             } finally {
                 tracker.clear();
                 objects.setSize(0);
             }
         } catch (final JSExn e) {
             final Exception e2 = e;
-            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(e2); }});
+            Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { callback.unpause(e2); }});
         } catch (final IOException e) {
             final Exception e2 = e;
-            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(new JSExn(e2)); }});
+            Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { callback.unpause(new JSExn(e2)); }});
         } catch (final XML.Exn e) {
             final Exception e2 = e;
-            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(new JSExn(e2)); }});
+            Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { callback.unpause(new JSExn(e2)); }});
         }
     }
 }