2 * Created on 15-Sep-2005
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
7 package org.vamsas.client.simpleclient;
9 import java.beans.EventHandler;
10 import java.beans.PropertyChangeEvent;
11 import java.beans.PropertyChangeListener;
12 import java.beans.PropertyChangeSupport;
13 import java.io.BufferedReader;
15 import java.util.Hashtable;
16 import java.util.Vector;
18 import org.vamsas.client.ClientHandle;
19 import org.vamsas.client.Events;
20 import org.vamsas.client.IClient;
21 import org.vamsas.client.IClientDocument;
22 import org.vamsas.client.SessionHandle;
23 import org.vamsas.client.UserHandle;
28 public class SimpleClient implements IClient {
30 UserHandle user = null;
32 SessionHandle session = null;
34 ClientHandle client = null;
38 * TODO: check that build substitution variables are correct
39 * @see org.vamsas.client.IClient#getAbout()
41 public String getAbout() {
42 return new String("VORBA SimpleClient version $version$ build $build$");
48 * @see org.vamsas.client.IClient#getSessionUrn()
50 public String getSessionUrn() {
51 return session.getSessionUrn();
57 * @see org.vamsas.client.IClient#getSessionHandle()
59 public SessionHandle getSessionHandle() {
66 * @see org.vamsas.client.IClient#getClientHandle()
68 public ClientHandle getClientHandle() {
75 * @see org.vamsas.client.IClient#getUserHandle()
77 public UserHandle getUserHandle() {
81 private Hashtable handlers = initHandlers();
83 private Vector listeners = new Vector();
86 * make all the PropertyChangeSupport objects for the
87 * events described in org.vamsas.client.Event
90 private static Hashtable initHandlers() {
91 Hashtable events = new Hashtable();
92 java.util.Iterator evt = Events.EventList.iterator();
93 while (evt.hasNext()) {
94 Object ths = evt.next();
95 events.put(ths, (Object) new PropertyChangeSupport(ths));
103 * @see org.vamsas.client.IClient#addDocumentUpdateHandler(java.util.EventListener)
105 public void addDocumentUpdateHandler(PropertyChangeListener evt) {
106 if (handlers.containsKey(Events.DOCUMENT_UPDATE)) {
108 ((PropertyChangeSupport) (handler = handlers.get(Events.DOCUMENT_UPDATE)))
109 .addPropertyChangeListener(evt);
110 listeners.add(handler);
111 listeners.add((Object) evt);
118 * @see org.vamsas.client.IClient#finalizeClient()
120 public void finalizeClient() {
121 // TODO: determine if this is last client in session
122 // TODO: raise events like : ((lst_client && document.request.to.close), (client_finalization), (
124 // if (handlers.containsKey(Events.))
125 // if (handlers.containsKey(Events.CLIENT_FINALIZATION))
126 // deregister listeners.
127 // mark this instance as finalized
131 * extract data appropriate for client, session and user
132 * from vamsas document.
133 * @return application's byte array
135 private byte[] getApplicationData() {
136 // TODO: extract correct byte object from Jar and return it to application.
143 * @see org.vamsas.client.IClient#getClientDocument()
145 public IClientDocument getClientDocument() {
146 Object[] vdoc;// TODO: = getVamsasDocument(new Reader());
147 // ClientDocument cdoc = new ClientDocument(getApplicationData(),
148 // ((VamsasDocument) vdoc[0]).getVAMSAS(), (Hashtable) vdoc[1], this);
156 * @see org.vamsas.client.IClient#updateDocument(org.vamsas.client.IClientDocument)
158 public void updateDocument(IClientDocument newdoc) {
159 // TODO Auto-generated method stub
166 * @see org.vamsas.client.IClient#storeDocument(java.io.File)
168 public void storeDocument(File location) {
169 // TODO Auto-generated method stub
176 * @see org.vamsas.client.IClient#addVorbaEventHandler(java.lang.String,
177 * java.beans.PropertyChangeListener)
179 public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt) {
180 if (handlers.containsKey(EventChain)) {
182 ((PropertyChangeSupport) (handler = handlers.get(EventChain)))
183 .addPropertyChangeListener(evt);
184 listeners.add(handler);
185 listeners.add((Object) evt);
190 * @see org.vamsas.client.IClient#pollUpdate()
192 public void pollUpdate() {
193 // TODO wake up UpdateWatcher thread to check for updates.
197 public static void main(String[] args) {
201 * @see org.vamsas.client.IClient#joinSession()
203 public void joinSession() throws Exception {
204 // TODO Auto-generated method stub