generalised ArchiveReports functions to output on any stream.
[vamsas.git] / src / org / vamsas / test / ExampleApplication.java
index 297d48d..520f668 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * Created on 14-Sep-2005
  *
  * TODO To change the template for this generated file go to
@@ -11,6 +11,7 @@ import org.vamsas.client.*;
 import java.awt.Event;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.IOException;
 import java.util.Vector;
 /**
  * Toy vamsas command line client application demonstrating the API.
@@ -80,7 +81,15 @@ public class ExampleApplication {
         System.out.println("Session "+evt.getPropertyName()+" is shutting down.");
         // tell app to finalize its session data before shutdown.
       }
-    });        
+    });
+    vorbaclient.addVorbaEventHandler(Events.DOCUMENT_FINALIZEAPPDATA, 
+        new PropertyChangeListener() {
+      public void propertyChange(PropertyChangeEvent evt) {
+        System.out.println("Application received a DOCUMENT_FINALIZEAPPDATA event.");
+        // tell app to finalize its session data prior to the storage of the current session as an archive.
+      }
+    });
+    
   }
   public static String 
        Usage="ExampleApplication <vamsasFileDirectory> <vamsasSessionURN> <action> [+<arguments>]\n"
@@ -95,13 +104,26 @@ public class ExampleApplication {
     }
 
     // get IClientFactory
-    clientfactory = new org.vamsas.client.SimpleClientFactory(args[0]);
+    try {
+      clientfactory = new org.vamsas.client.simpleclient.SimpleClientFactory(args[0]);
+    } catch (IOException e) {
+      System.err.println(e+"\n"+Usage);
+      System.exit(1);
+    }
     
     // get an Iclient with session data
     app = new ClientHandle("org.vamsas.test.ExampleApplication","0.1");
     user = new UserHandle("arnolduser","deathsdoor");
     vorbaclient = clientfactory.getIClient(app, user);
     addHandlers(vorbaclient);
+    try {
+      vorbaclient.joinSession();
+    }
+    catch (Exception se) {
+      se.printStackTrace();
+      System.err.println(se+" when joining session.\n"+Usage);
+      System.exit(1);
+    }
     // register an update listener and a close listener.
     // get document data
     processVamsasDocument(vorbaclient.getClientDocument());