removed dependencies on the core
authoradam <adam@megacz.com>
Fri, 3 Sep 2004 00:44:12 +0000 (00:44 +0000)
committeradam <adam@megacz.com>
Fri, 3 Sep 2004 00:44:12 +0000 (00:44 +0000)
darcs-hash:20040903004412-5007d-24e9eb757bf3c94917a8499eb7556b93793a048a.gz

src/org/ibex/net/SOAP.java
src/org/ibex/net/XMLRPC.java

index 85670a3..b33bfb6 100644 (file)
@@ -90,7 +90,7 @@ public class SOAP extends XMLRPC {
 
             } else if (me instanceof byte[]) {
                 objects.removeElementAt(objects.size() - 1);
-                objects.addElement(new Stream.ByteArray(Base64.decode(new String(content.getBuf(), 0, content.size())), null));
+                objects.addElement(new Fountain.ByteArray(Base64.decode(new String(content.getBuf(), 0, content.size())), null));
                 content.reset();                
 
             } else if (me instanceof Integer) {
@@ -179,10 +179,10 @@ public class SOAP extends XMLRPC {
             sb.append(((Boolean)o).booleanValue() ? "true" : "false");
             sb.append("</" + name + ">\r\n");
 
-        } else if (o instanceof Stream) {
+        } else if (o instanceof Fountain) {
             try {
                 sb.append("                <" + name + " xsi:type=\"SOAP-ENC:base64\">\r\n");
-                InputStream is = ((Stream)o).getInputStream();
+                InputStream is = ((Fountain)o).getInputStream();
                 byte[] buf = new byte[54];
                 while(true) {
                     int numread = is.read(buf, 0, 54);
@@ -199,9 +199,9 @@ public class SOAP extends XMLRPC {
                 sb.append(((Boolean)o).booleanValue() ? "1" : "0");
                 sb.append("</" + name + ">\r\n");
             } catch (IOException e) {
-                if (Log.on) Log.info(this, "caught IOException while attempting to send a ByteStream via SOAP");
+                if (Log.on) Log.info(this, "caught IOException while attempting to send a Fountain via SOAP");
                 if (Log.on) Log.info(this, e);
-                throw new JSExn("caught IOException while attempting to send a ByteStream via SOAP");
+                throw new JSExn("caught IOException while attempting to send a Fountain via SOAP");
             }
 
         } else if (o instanceof String) {
index 14aacb5..984d485 100644 (file)
@@ -98,7 +98,7 @@ public class XMLRPC extends JS {
             case "string": objects.setElementAt(new String(content.getBuf(), 0, content.size()), objects.size() - 1);
             case "double": objects.setElementAt(new Double(new String(content.getBuf(), 0, content.size())), objects.size() - 1);
             case "base64":
-                objects.setElementAt(new Stream.ByteArray(Base64.decode(new String(content.getBuf(), 0, content.size())),
+                objects.setElementAt(new Fountain.ByteArray(Base64.decode(new String(content.getBuf(), 0, content.size())),
                                                           null), objects.size() - 1);
             case "name": objects.addElement(new String(content.getBuf(), 0, content.size()));
             case "value": if ("".equals(objects.lastElement()))
@@ -207,10 +207,10 @@ public class XMLRPC extends JS {
             sb.append(((Boolean)o).booleanValue() ? "1" : "0");
             sb.append("</boolean></value>\n");
 
-        } else if (o instanceof Stream) {
+        } else if (o instanceof Fountain) {
             try {
                 sb.append("                <value><base64>\n");
-                InputStream is = ((Stream)o).getInputStream();
+                InputStream is = ((Fountain)o).getInputStream();
                 byte[] buf = new byte[54];
                 while(true) {
                     int numread = is.read(buf, 0, 54);
@@ -226,9 +226,9 @@ public class XMLRPC extends JS {
                 }
                 sb.append("\n              </base64></value>\n");
             } catch (IOException e) {
-                if (Log.on) Log.info(this, "caught IOException while attempting to send a ByteStream via XML-RPC");
+                if (Log.on) Log.info(this, "caught IOException while attempting to send a Fountain via XML-RPC");
                 if (Log.on) Log.info(this, e);
-                throw new JSExn("caught IOException while attempting to send a ByteStream via XML-RPC");
+                throw new JSExn("caught IOException while attempting to send a Fountain via XML-RPC");
             }
 
         } else if (o instanceof String) {
@@ -301,6 +301,7 @@ public class XMLRPC extends JS {
 
     // Call Sequence //////////////////////////////////////////////////////////////////////////
 
+    /* FIXME this has been disabled to make XMLRPC usable without Scheduler
     public final Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
         JSArray args = new JSArray();
         for(int i=0; i<nargs; i++) args.addElement(i==0?a0:i==1?a1:i==2?a2:rest[i-3]);
@@ -316,33 +317,35 @@ public class XMLRPC extends JS {
             throw new JSExn("cannot invoke an XML-RPC call in the foreground thread");
         }
     }
+    */
 
-    final void call(final JS.UnpauseCallback callback, final JSArray args) {
+    // FIXME need to reenable backgrounding logic
+    final Object call(final JS.UnpauseCallback callback, final JSArray args) {
         try {
             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.rpc) Log.info(this, "send:\n" + request);
-            InputStream is = http.POST("text/xml", request);
+            InputStream is = http.POST("text/xml", request, null, null);
             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 Task() { public void perform() throws JSExn { callback.unpause(result); }});
+                return (new 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 Task() { public void perform() throws JSExn { callback.unpause(e2); }});
+            return (new Task() { public void perform() throws JSExn { callback.unpause(e2); }});
         } catch (final IOException e) {
             final Exception e2 = e;
-            Scheduler.add(new Task() { public void perform() throws JSExn { callback.unpause(new JSExn(e2)); }});
+            return (new Task() { public void perform() throws JSExn { callback.unpause(new JSExn(e2)); }});
         } catch (final XML.Exn e) {
             final Exception e2 = e;
-            Scheduler.add(new Task() { public void perform() throws JSExn { callback.unpause(new JSExn(e2)); }});
+            return (new Task() { public void perform() throws JSExn { callback.unpause(new JSExn(e2)); }});
         }
     }
 }