From: jprocter Date: Mon, 8 Jun 2009 12:28:41 +0000 (+0000) Subject: store simpleclientsession handle rather than bare sessionhandle X-Git-Tag: Release_0.2~20 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b6db4e92aa4e682f878801185a755130331e65c7;p=vamsas.git store simpleclientsession handle rather than bare sessionhandle git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@501 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java b/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java index 5730317..afcdb1c 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java @@ -31,6 +31,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import uk.ac.vamsas.client.SessionHandle; +import uk.ac.vamsas.client.simpleclient.SimpleSessionHandle; /** * @author Pierre MARGUERITE @@ -67,10 +68,10 @@ public class SessionsFile extends ListFile { * * @return list of clients */ - private SessionHandle[] retrieveSessionHandles() { + private SimpleSessionHandle[] retrieveSessionHandles() { if (lockFile()) { try { - SessionHandle[] sessions = null; + SimpleSessionHandle[] sessions = null; if (this.fileLock.length() > 0) { ObjectInputStream is = new ObjectInputStream(this.fileLock @@ -79,7 +80,7 @@ public class SessionsFile extends ListFile { o = is.readObject(); if (o != null) { try { - sessions = (SessionHandle[]) o; + sessions = (SimpleSessionHandle[]) o; } catch (Exception e) { log.error("Garbage in the clientHandle list " + this.sessionFile, e); @@ -104,9 +105,9 @@ public class SessionsFile extends ListFile { * * @return sessionsList */ - public SessionHandle[] retrieveSessionsList() { + public SimpleSessionHandle[] retrieveSessionsList() { if (lockFile()) { - SessionHandle[] clients = retrieveSessionHandles(); + SimpleSessionHandle[] clients = retrieveSessionHandles(); unlockFile(); return clients; } @@ -119,9 +120,9 @@ public class SessionsFile extends ListFile { * @param extantlock * @return sessionList or null if lock failed (or file was empty) */ - public SessionHandle[] retrieveSessionsList(Lock extantlock) { + public SimpleSessionHandle[] retrieveSessionsList(Lock extantlock) { if (lockFile(extantlock)) { - SessionHandle[] sessions = retrieveSessionHandles(); + SimpleSessionHandle[] sessions = retrieveSessionHandles(); unlockFile(); return sessions; } @@ -136,7 +137,7 @@ public class SessionsFile extends ListFile { * @return session index in list or 0 if lock was invalid or addSession * operation failed. */ - public int addSession(SessionHandle newSession, Lock extantLock) { + public int addSession(SimpleSessionHandle newSession, Lock extantLock) { return addSession(newSession, true, extantLock); } @@ -153,7 +154,7 @@ public class SessionsFile extends ListFile { * @return client index in list or 0 if addSession (or the lock) failed. */ - public int addSession(SessionHandle newSession, boolean disambig, + public int addSession(SimpleSessionHandle newSession, boolean disambig, Lock extantLock) { if (lockFile(extantLock)) { this.syncnum = addSession(newSession, disambig); @@ -176,10 +177,10 @@ public class SessionsFile extends ListFile { int mynum = -1; if (lockFile(sessionlock)) { - SessionHandle[] sessions = retrieveSessionHandles(); + SimpleSessionHandle[] sessions = retrieveSessionHandles(); if (sessions != null) { if ((this.syncnum <= 0 || this.syncnum > sessions.length) - || !sessions[this.syncnum - 1].equals(session)) { + || !session.equals(sessions[this.syncnum - 1])) { for (int i = 0, j = sessions.length; i < j; i++) { if (sessions[i].equals(session)) { mynum = i; @@ -191,7 +192,7 @@ public class SessionsFile extends ListFile { } if (mynum > -1) { - SessionHandle[] newlist = new SessionHandle[sessions.length - 1]; + SimpleSessionHandle[] newlist = new SimpleSessionHandle[sessions.length - 1]; for (int k = 0, i = 0, j = sessions.length; i < j; i++) if (i != mynum) newlist[k++] = sessions[i]; @@ -223,7 +224,7 @@ public class SessionsFile extends ListFile { * @return index of sessionHandle in new list, or -1-position of existing * sessionHandle (if disambiguate is true) */ - protected int addSession(SessionHandle session, boolean disambiguate) { + protected int addSession(SimpleSessionHandle session, boolean disambiguate) { int newsession = 0; int tries = 5; while (tries-- > 0 && !lockFile()) @@ -233,10 +234,10 @@ public class SessionsFile extends ListFile { } ; if (lockFile()) { - SessionHandle[] sessions = retrieveSessionHandles(); + SimpleSessionHandle[] sessions = retrieveSessionHandles(); if (sessions == null) { - sessions = new SessionHandle[1]; + sessions = new SimpleSessionHandle[1]; sessions[0] = session; newsession = 1; } else { @@ -258,7 +259,7 @@ public class SessionsFile extends ListFile { } } int i, j; - SessionHandle[] newlist = new SessionHandle[sessions.length + 1]; + SimpleSessionHandle[] newlist = new SimpleSessionHandle[sessions.length + 1]; for (i = 0, j = sessions.length; i < j; i++) newlist[i] = sessions[i]; newlist[j] = session; @@ -277,7 +278,7 @@ public class SessionsFile extends ListFile { * @param clients * @return true if successful write. Throws Errors otherwise. */ - protected boolean putSessionsList(SessionHandle[] clients) { + protected boolean putSessionsList(SimpleSessionHandle[] clients) { if (lockFile()) { File templist = null; if (!this.backup || (templist = backupSessionFile()) != null) {