VamsasSession: insure the RemoveClientWatchCallBack handleWatchEvent method. no...
authorpmarguerite <pmarguerite@issues.jalview.org>
Fri, 18 May 2007 14:48:31 +0000 (14:48 +0000)
committerpmarguerite <pmarguerite@issues.jalview.org>
Fri, 18 May 2007 14:48:31 +0000 (14:48 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@395 be28352e-c001-0410-b1a7-c7978e42abec

src/uk/ac/vamsas/client/simpleclient/VamsasSession.java

index b066f88..dcffe57 100644 (file)
@@ -402,6 +402,8 @@ public class VamsasSession {
       public boolean handleWatchEvent(WatcherElement watcher, Lock lock)
         {
           boolean isWatchEnable = watcher.isWatchEnabled();
+          if (lock== null)//no update on the list
+            return isWatchEnable;
           if (client != null)
             {
           
@@ -504,18 +506,19 @@ public class VamsasSession {
        * @return true to enable watcher, or false to disable it in future WatcherThread cycles.
        */
       public boolean handleWatchEvent(WatcherElement watcher, Lock lock)
-        {
-         // boolean isWatchEnable = watcher.isWatchEnabled();
-          if (client != null)
+        { 
+        // if lock is null, no client has been added since last, clear.
+        //the client is then the last client
+          if (client != null && lock == null)
             {
             
             //checks if the client is not already in the lists
-              ClientHandle[] cl = clist.retrieveClientList(lock);//clist.retrieveClientList();
+           //   ClientHandle[] cl = clist.retrieveClientList();//lock);//clist.retrieveClientList();
 //            ask to the client to cpoy application data into the document
               client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, client,null);
 
-              if(cl == null || cl.length<1 )
-                {//no client has registered as active
+            //  if(cl == null || cl.length<1 )
+              //  {//no client has registered as active
                 //the client is the last one, so close current session
                   log.info("last client removed: closing session");
 
@@ -525,20 +528,17 @@ public class VamsasSession {
                   
                   getSessionManager().removeSession(client.getSessionHandle());
                   log.debug("Session removed");
-                }
-              else
-                {
+            }
+          else
+          {
                 log.debug("not the last client found ");
 //              ask to the client to cpoy application data into the document
        //         client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, client,null);
 
-                }
-             // watcher.haltWatch();
-              log.debug("Stopping EventGenerator..");
-              client.evgen.stopWatching();
-            
-
-            }
+           //   /  }
+                log.debug("Stopping EventGenerator..");
+                client.evgen.stopWatching();
+          }
           watcher.setHandler(null);//Do not check if the client is the last client. watcher will shutdown anyway
          
           return false;