- 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 void propertyChange(PropertyChangeEvent evt) {
+ boolean finalized = false;
+ System.out
+ .println("Application received a DOCUMENT_FINALIZEAPPDATA event.");
+ IClientDocument cdoc = null;
+ try {
+ cdoc = vorbaclient.getClientDocument();
+ if (cdoc != null) {
+ IClientAppdata apd = cdoc.getClientAppdata();
+ if (apd != null) {
+ String userd = "";
+ if (apd.getUserAppdata()!=null)
+ {
+ userd = new String(apd.getUserAppdata());
+ }
+ String appdat = me.readData(apd.getClientInputStream());
+ me.writeData(apd.getClientOutputStream(), appdat
+ + "\nUser Data merged\n" + userd + "\n");
+ }
+ finalized = true;
+ vorbaclient.updateDocument(cdoc);
+ }
+ // tell app to finalize its session data prior to the
+ // storage of the current session as an archive.
+ } catch (Exception e) {
+ if (!finalized) {
+ System.err
+ .println("Probable library problem - exception when trying to update document after writing merged appdata.");
+ e.printStackTrace(System.err);
+ } else {
+ System.err
+ .println("Recovering from exception when writing merged appdata");
+ e.printStackTrace(System.err);
+ try {
+ if (cdoc != null) {
+ vorbaclient.updateDocument(cdoc);
+ }
+ } catch (Exception e2) {
+ System.err
+ .println("Probable library problem - exception when trying to update document after an exception when writing merged appdata.");
+ e2.printStackTrace(System.err);
+ }
+ }
+ return;
+ }
+ System.out.println("Application finalized appdata successfuly.");
+ }