package uk.ac.vamsas.test;
import uk.ac.vamsas.client.*;
+import uk.ac.vamsas.client.picking.IMessageHandler;
+import uk.ac.vamsas.client.picking.IPickManager;
+import uk.ac.vamsas.client.picking.Message;
import uk.ac.vamsas.objects.core.VAMSAS;
import uk.ac.vamsas.test.objects.Core;
return true;
}
public static void main(String[] args) {
+ class ExamplePicker implements Runnable {
+ String me=null;
+ public IPickManager pm = null;
+ ExamplePicker(String me,IPickManager pm) {
+ this.me = me;
+ this.pm = pm;
+ }
+ public void run() {
+ int mcount=1;
+ while (pm!=null) {
+ try { Thread.sleep(1000+(long) Math.random()*10000); }
+ catch (Exception e){ };
+ if (pm!=null)
+ {
+ pm.sendMessage(new uk.ac.vamsas.client.picking.CustomMessage("Message "+mcount+++" from "+me));
+ }
+ }
+ }
+
+ };
if (!parseArgs(args)) {
System.err.print(Usage);
System.exit(1);
}
int update=0;
- // Main application event loop - wait around and do stuff...
+ ExamplePicker picker = new ExamplePicker(vorbaclient.getClientHandle().getClientUrn(),vorbaclient.getPickManager());
+ Thread pickthread = new Thread(picker);
+ pickthread.start();
+ picker.pm.registerMessageHandler(new IMessageHandler() {
+
+ public void handleMessage(Message message) {
+ System.out.println("Received |"+message.getRawMessage()+"|");
+ }
+
+ });
while (!isShuttingdown && update<5) {
// do something with data
// , update document, or something.
}
try { Thread.sleep(15); } catch (Exception e) {};
}
+ System.out.println("Shutting down picker.");
+ picker.pm=null;
+ while (pickthread.isAlive()) {
+ System.out.println("Waiting for picker to die...");
+ try { Thread.sleep(1000);
+ } catch (Exception e) {};
+ }
+
System.out.println("Finalizing.");
// call finalizeClient
vorbaclient.finalizeClient();
// finish
}
+
}