diff src/org/dancres/blitz/remote/nio/ResultReceiver.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/dancres/blitz/remote/nio/ResultReceiver.java	Sat Mar 21 11:00:06 2009 +0000
@@ -0,0 +1,36 @@
+package org.dancres.blitz.remote.nio;
+
+import java.rmi.RemoteException;
+
+/**
+ */
+public class ResultReceiver implements ResultProcessor {
+    private byte[] _payload;
+    private RemoteException _throwable;
+
+    public synchronized void deliver(byte[] aPayload) {
+        // System.err.println("Deliver");
+        _payload = aPayload;
+        notify();
+    }
+
+    public synchronized void deliver(RemoteException aT) {
+        _throwable = aT;
+        notify();
+    }
+
+    synchronized byte[] getPayload() throws RemoteException {
+        while ((_payload == null) && (_throwable == null)) {
+            try {
+                wait();
+            } catch (InterruptedException anIE) {
+            }
+        }
+
+        if (_throwable != null)
+                throw _throwable;
+
+        // System.err.println("Got payload: " + _payload.length);
+        return _payload;
+    }
+}