2 * uk.ac.vamsas.client.IClient
5 package uk.ac.vamsas.client;
7 import java.beans.PropertyChangeListener;
8 import java.io.IOException;
11 * Defines the methods availabable to a vamsas
12 * application for interacting with its Vorba agent
13 * created by an IClientFactory instance for a particular session,
14 * user, and application handle.
15 * (it's VORBA, not CORBA!)
16 * LATER: add exceptions for timeouts raised when there are problems accessing session data (because another application is hogging it).
17 * LATER: think about situations when two applications both want a ClientDocument at the same time - can one have read-only access (and be told that another is about to update)
20 public interface IClient {
23 * Self-documenting/describing info for the application to present
25 * LATER: formalise this for describing VAMSAS system, a particular
26 * Vorba client agent, and a particular session.
27 * @return string like VamsasClient v.1.1.1 (GPL) and whatever
29 public String getAbout();
32 * convenience method to get the SessionUrn as a string (for passing directly to a text box...).
33 * @return current SessionUrn
35 public String getSessionUrn();
37 * Returns a valid URN for other applications to connect to
39 * @return session handle for this session.
41 public SessionHandle getSessionHandle();
43 * Included for applications with several ClientHandle
45 * @return ClientHandle used to interact with
46 * other Vamsas applications.
48 public ClientHandle getClientHandle();
51 * @return UserHandle used when interacting
52 * with other Vamsas applications.
54 public UserHandle getUserHandle();
56 * Method called by client application on exit.
57 * Vorba will inform other clients if they exist.
58 * If this is the last application in the session
59 * then the session will be closed.
60 * Note: The application should be ready to handle
61 * 'RequestToCloseDocument' events from the Vorba
62 * agent in the latter case and so prompt the user
63 * to save the session locally.
64 * LATER: pick a better name ?
66 public void finalizeClient();
68 * register handler for updates for the current session
70 public void addDocumentUpdateHandler(PropertyChangeListener evt);
72 * get vamsas document with
73 * user and app specific data
74 * IClientDocuments are not thread-safe.
75 * TODO: New exception for failed document lock.
76 * @throws IOException if lock is not obtainable for the document in the session
78 public IClientDocument getClientDocument() throws IOException;
80 * Queue new Vorba objects for storage and propagation
81 * to other clients (via Event.DOCUMENT_UPDATE based
82 * notification of document change)
83 * New objects without provenance information will be
84 * given a default entry using the IClient's application,
85 * user (and session) handles
86 * Validity of IClientDocument object instances after this call is implementation dependent
87 * TODO: consider refactoring to remove the redundant IClientDocument parameter for this method
89 public void updateDocument(IClientDocument newdoc);
91 * Any application may call storeDocument to
92 * save a local copy of the current vamsas document
93 * including all application specific entries.
95 * @param location to write zip file
97 public void storeDocument(java.io.File location);
99 * Any application may call importDocument to merge a stored
100 * vamsasDocument into the current session.
101 * Note: use a IClientFactory's implementation to make sessions out of vamsas documnts
102 * LATER: VAMSAS: The IClient implementation will handle all ID 'relocations'
105 public void importDocument(java.io.File location);
107 * Add a listener to a particular event chain.
108 * See uk.ac.vamsas.client.Events for allowed
109 * values for EventChain.
110 * The EventChain value is passed as the
111 * propertyName in the java.bean.PropertyChangeEvent
112 * LATER: extend class to form own vamsas Event/Listener model.
113 * @param EventChain Name of event. Blank/null registers handler for all events.
114 * @param evt - event handler function.
116 public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt);
118 * Sets the update handler that will be called when any updates occur to objects of type rootObject.
122 public void setUpdateHandler(IObjectUpdate handler);
123 public IObjectUpdate getUpdateHandler(Class rootObject);
124 public void removeUpdateHandler(Class rootObject);
125 public IObjectUpdate[] getUpdateHandlers();
127 * client application calls this to force the
128 * Vorba client to check for updates immediately.
131 public void pollUpdate();
134 * Client application calls this after any pre-session initialization
135 * (registering of Handlers, etc)
136 * Exceptions are raised for any failures. Any stateful calls to the session prior to
137 * this will result in an implicit call to joinSession - if that results in an exception
138 * then the VamsasClient should raise an Error.
139 * LATER: create VAMSAS exception hierarchy (in a language agnostic manner)
141 public void joinSession() throws Exception;
143 * get the Vamsas Pick Manager for registering pick handlers and sending messages for the current session.
144 * @return an object implementing IPickManager (which maybe the same as the IClient implementer)
146 public uk.ac.vamsas.client.picking.IPickManager getPickManager();