- this.filelist = filelist;
- if (!this.filelist.exists())
- this.filelist.createNewFile();
- }
-
- private Lock listlock = null;
-
- /**
- * Get a lock for the ClientsFile
- *
- * @return true if lock was made
- */
- protected boolean lockList() {
- if (listlock != null && listlock.isLocked())
- return true;
- 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 {
- // 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 boolean unlockList() {
- if (listlock != null) {
-
- if (listlock.isLocked()) {
- try {
- listlock.lock.release();
- } catch (IOException e) {
- // TODO Deal with unlock Lock.release exception!
- e.printStackTrace(System.err);
- }
- }
-
- listlock = null;
- return true;
- }
- return false;