- this.filelist = filelist;
- if (!this.filelist.exists())
- this.filelist.createNewFile();
- }
-
- private Lock listlock = null;
-
- protected boolean lockList(Lock extantlock) {
- if (listlock!=null && !listlock.isLocked()) {
- listlock.release();// tidy up invalid lock
- }
- listlock=extantlock;
- return lockList();
- }
- /**
- * Get a lock for the ClientsFile
- *
- * @return true if lock was made
- */
- protected boolean lockList() {
- if (listlock != null)
- if (listlock.isLocked())
- return true;
- else
- // lock failed for some reason.
- listlock.release();
- listlock = null;
- if (filelist != null) {
- if (filelist.exists()) {
- // TODO: see if we need to loop-wait for locks or they just block until
- // lock is made...
- do {
- if (listlock!=null)
- listlock.release();
- listlock = new Lock(filelist); // TODO: wait around if we can't get the lock.
- } while (!listlock.isLocked());
- // listlock = new Lock(filelist);
- return listlock.isLocked();
- }
- } else
- throw new Error(
- "org.vamsas.client.simpleclient.ClientsFile.lockList called for non-initialised ClientsFile!");
-
- // no lock possible
- return false;
- }
-
- /**
- * Explicitly release the ClientsFile lock.
- *
- * @return true if lock was released.
- */
- protected void unlockList() {
- if (listlock != null) {
- listlock.release();
- listlock = null;
- }