From: jprocter Date: Tue, 25 Oct 2005 13:28:45 +0000 (+0000) Subject: added more extantLock methods and test for clientList monitoring (using FileWatcher... X-Git-Tag: Release_0.2~443 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=37e460acf0f82dfb3dfeeb022a84f737759921ba;p=vamsas.git added more extantLock methods and test for clientList monitoring (using FileWatcher.setState()) git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@77 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/org/vamsas/client/simpleclient/ClientsFile.java b/src/org/vamsas/client/simpleclient/ClientsFile.java index e5cbc72..d0fe340 100644 --- a/src/org/vamsas/client/simpleclient/ClientsFile.java +++ b/src/org/vamsas/client/simpleclient/ClientsFile.java @@ -147,7 +147,33 @@ public class ClientsFile { } return null; } - + /** + * adds clientHandle me to the clientList under an existing lock extantLock. + * @param me + * @param extantLock + * @return client index in list or 0 if lock was invalid or addClient operation failed. + */ + public int addClient(ClientHandle me, Lock extantLock) { + return addClient(me, true, extantLock); + } + + /** + * adds clientHandle me to the clientList under an existing lock. + * @param me - clientHandle + * @param disambig - if true then add will fail if an identical clientHandle already exists + * @param extantLock - existing lock + * @return client index in list or 0 if addClient (or the lock) failed. + */ + + public int addClient(ClientHandle me, boolean disambig, Lock extantLock) { + if (lockList(extantLock)) { + syncnum = addClient(me, disambig); + unlockList(); + return syncnum; + } + return 0; + } + /** * adds the ClientHandle to the list - if it is not unique, then the * ClientHandle object is modified to make it unique in the list. returns the diff --git a/src/org/vamsas/client/simpleclient/FileWatcher.java b/src/org/vamsas/client/simpleclient/FileWatcher.java index 34897a8..40038ad 100644 --- a/src/org/vamsas/client/simpleclient/FileWatcher.java +++ b/src/org/vamsas/client/simpleclient/FileWatcher.java @@ -93,12 +93,16 @@ public class FileWatcher { } return false; } - + /** + * updates internal record of file state when caller has intentionally + * modified subject. + */ public void setState() { if (subject!=null) { - lastStat = getStat(subject); - exists = subject.exists(); - waslocked = checkLock(); + if (exists = subject.exists()) { + lastStat = getStat(subject); + waslocked = false; + } } } diff --git a/src/org/vamsas/test/simpleclient/ClientsFileTest.java b/src/org/vamsas/test/simpleclient/ClientsFileTest.java index a149a16..6ccd736 100644 --- a/src/org/vamsas/test/simpleclient/ClientsFileTest.java +++ b/src/org/vamsas/test/simpleclient/ClientsFileTest.java @@ -18,6 +18,7 @@ public class ClientsFileTest { ClientsFileTest.commands.add(new String("list")); ClientsFileTest.commands.add(new String("clear")); ClientsFileTest.commands.add(new String("watch")); + ClientsFileTest.commands.add(new String("monitor")); } private static void complainArgs(int argl, int argpos, String cmd, int argneed, String msg) { if (argl-argpos