fixed probable bug
[vamsas.git] / src / org / vamsas / client / Events.java
1 package org.vamsas.client;
2
3 /**
4  * Enumerates the event types generated during the lifecycle of a Vamsas
5  * session.
6  */
7
8 public class Events {
9   /**
10    * Generated when a client has finished updating the document. Passes
11    * applicationHandle of client so the updating client can recognise its own
12    * updates.
13    */
14   public static final String DOCUMENT_UPDATE = "org.vamsas.client.events.documentUpdateEvent";
15
16   /**
17    * Generated when a new vamsas document is created (perhaps from some existing
18    * Vamsas data) so an application may do its own data space initialization.
19    * TODO: decide if this is called when an app is connected to a stored
20    * session...
21    */
22   public static final String DOCUMENT_CREATE = "org.vamsas.client.events.documentCreateEvent";
23
24   /**
25    * Generated when a new vamsas client is attached to a session (Handle is
26    * passed) Note: the newly created client does not receive the event.
27    */
28   public static final String CLIENT_CREATION = "org.vamsas.client.events.clientCreateEvent";
29
30   /**
31    * Generated when a vamsas client leaves a session (Handle is passed to all
32    * others).
33    */
34   public static final String CLIENT_FINALIZATION = "org.vamsas.client.events.clientFinalizationEvent";
35
36   /**
37    * Generated prior to session Shutdown, after the last participating vamsas
38    * client has finalized.
39    */
40   public static final String SESSION_SHUTDOWN = "org.vamsas.client.events.SessionShutdownEvent";
41
42   /**
43    * Generated for all clients when any client calls IClient.storeDocument() to
44    * allow them to store any updates before an offline copy of the session is
45    * created. Any client that handles this should call the
46    * IClient.getDocument(), update and then IClient.updateDocument in the same
47    * handler thread (the lock on the document is held until the handler exits).
48    * EventName: <Vamsas-session URN>
49    * NewValue: org.vamsas.client.IClient for session.
50    */
51   public static final String DOCUMENT_FINALIZEAPPDATA = "org.vamsas.client.events.DocumentFinalizeAppData";
52
53   /**
54    * Generated by Vorba stub for the sole remaining client, after the penultimate 
55    * client makes a call to finalizeClient(). It is only raised if the session has been modifies since the 
56    * last call to storeDocument() by any application.
57    * TODO: LATER: copies of a document should be on a per-user basis for multi-user sessions. 
58    *  Sequence is as follows : 1. All other vamsas clients have
59    * called finalizeClient() 2. Final living client monitors closures, and
60    * realises that it is last. 3. Final client generates event to prompt
61    * associated application to inquire if the user wishes to save the document
62    * for future reference.
63    *  * Any call to finalizeClient in a thread other than the registered
64    * EventListener will block until the RequestToClose handler has exited.
65    * 
66    */
67   public static final String DOCUMENT_REQUESTTOCLOSE = "org.vamas.client.DocumentRequestToCloseEvent";
68
69   public static java.util.Vector EventList = initList();
70
71   private static java.util.Vector initList() {
72     java.util.Vector vec = new java.util.Vector();
73     vec.add((Object) DOCUMENT_UPDATE);
74     vec.add((Object) DOCUMENT_CREATE);
75     vec.add((Object) CLIENT_CREATION);
76     vec.add((Object) CLIENT_FINALIZATION);
77     vec.add((Object) SESSION_SHUTDOWN);
78     vec.add((Object) DOCUMENT_REQUESTTOCLOSE);
79     vec.add((Object) DOCUMENT_FINALIZEAPPDATA);
80     return vec;
81   }
82 }