import java.awt.Event;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.File;
import java.io.IOException;
import java.util.Vector;
}
- public String Usage = "ExampleApplication [session urn] watch/n( future usage is :/n <vamsasFileDirectory> <vamsasSessionURN> <action> [+<arguments>]\n"
+ public String Usage = "ExampleApplication :/n [-arena <vamsasFileDirectory>][-session <vamsasSessionURN>] <action> [+<arguments>]\n"
+ "<action> is one of :\n\tsave,update,close,watch";
String sess = null;
-
+ String importFile=null;
+ String outputFile=null;
private boolean parseArgs(String args[])
{
if (args.length == 0)
{
return false;
}
- if (!args[0].toLowerCase().equals("watch"))
+ int cpos=0;
+ boolean parsed=false;
+ while (!parsed && cpos<args.length)
{
- sess = args[0];
+ if (args[cpos].toLowerCase().equals("load") && cpos+1<args.length)
+ {
+ importFile=args[cpos+1];
+ cpos+=2;
+ continue;
+ }
+ if (args[cpos].toLowerCase().equals("save") && cpos+1<args.length)
+ {
+ outputFile=args[cpos+1];
+ cpos+=2;
+ continue;
+ }
+ // default behaviour - if not anything else its probably a session urn
+ if (!args[cpos].toLowerCase().equals("watch"))
+ {
+ sess = args[cpos];
+ }
+ cpos++;
}
return true;
}
-
+
class ExamplePicker extends Thread
{
String me = null;
user = new UserHandle("arnolduser", "deathsdoor");
try
{
- vorbaclient = clientfactory.getIClient(app, user);
+ if (sess!=null)
+ {
+ System.out.println("Connecting to "+sess);
+ vorbaclient = clientfactory.getIClient(app, user, sess);
+ }
+ else
+ {
+ vorbaclient = clientfactory.getIClient(app, user);
+ }
}
catch (NoDefaultSessionException e)
{
System.exit(1);
}
// register an update listener and a close listener.
+ // import any data if requested to
+ if (importFile!=null)
+ {
+ File vfile = new File(importFile);
+ try
+ {
+ vorbaclient.importDocument(vfile);
+ }
+ catch (Exception e)
+ {
+ System.err.println("Failed to import file "+importFile);
+ System.err.println("Exception received was "+e);
+ e.printStackTrace(System.err);
+ }
+
+ }
+ // Write out any data if requested to
+ if (outputFile!=null)
+ {
+ File vfile = new File(outputFile);
+ try
+ {
+ vorbaclient.storeDocument(vfile);
+ }
+ catch (Exception e)
+ {
+ System.err.println("Failed to export session as file "+outputFile);
+ System.err.println("Exception received was "+e);
+ e.printStackTrace(System.err);
+ }
+ }
// get document data
try
{
}
}
- try { Thread.sleep(15); }
+ try { Thread.sleep(50); }
catch (Exception e) {}
}