aboutsummaryrefslogtreecommitdiff
path: root/src/WaiterClient.java
diff options
context:
space:
mode:
authorjestin2004-07-30 12:55:46 +0000
committerjestin2004-07-30 12:55:46 +0000
commitbe5724a2d22decb502d81e8d88a5922fbffa5f33 (patch)
treed7e2e00b1f3ae79ca51fd929be9ed28bdc648bc9 /src/WaiterClient.java
parent23dd2856594e8cdbc0fd0a18349bf61059d624c8 (diff)
downloadivy-java-be5724a2d22decb502d81e8d88a5922fbffa5f33.zip
ivy-java-be5724a2d22decb502d81e8d88a5922fbffa5f33.tar.gz
ivy-java-be5724a2d22decb502d81e8d88a5922fbffa5f33.tar.bz2
ivy-java-be5724a2d22decb502d81e8d88a5922fbffa5f33.tar.xz
ooops, those should have been in the repository ...
Diffstat (limited to 'src/WaiterClient.java')
-rw-r--r--src/WaiterClient.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/WaiterClient.java b/src/WaiterClient.java
new file mode 100644
index 0000000..931a048
--- /dev/null
+++ b/src/WaiterClient.java
@@ -0,0 +1,55 @@
+/**
+ * @author Yannick Jestin
+ * @author <a href="http://www.tls.cena.fr/products/ivy/">http://www.tls.cena.fr/products/ivy/</a>
+ *
+ * CHANGELOG:
+ * 1.2.4:
+ */
+
+package fr.dgac.ivy ;
+import java.util.*;
+
+class WaiterClient extends IvyApplicationAdapter implements Runnable {
+ private static final int INCREMENT = 100;
+ int timeout;
+ private IvyClient received=null;
+ private boolean forever=false;
+ private Thread t;
+ String name;
+
+ WaiterClient(String n,int timeout) {
+ this.timeout=timeout;
+ name=n;
+ if (timeout<=0) forever=true;
+ t=new Thread(this);
+ }
+
+ IvyClient waitForClient() {
+ t.start();
+ try { t.join(); } catch (InterruptedException ie) { return null; }
+ return received;
+ }
+
+ public void run() {
+ boolean encore=true;
+ // System.out.println("DEV WaiterClient start");
+ while (encore) {
+ try {
+ t.sleep(INCREMENT);
+ if (!forever) {
+ timeout-=INCREMENT;
+ if (timeout<=0) encore=false;
+ }
+ } catch (InterruptedException ie) {
+ break;
+ }
+ }
+ // System.out.println("DEV WaiterClient stop");
+ }
+
+ public void connect(fr.dgac.ivy.IvyClient client) {
+ if (name.compareTo(client.getApplicationName())!=0) return;
+ received=client;
+ t.interrupt();
+ }
+ }