package org.vamsas.client.simpleclient;
+import java.io.File;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
log.warn("System property vamsas.locktype takes one of "+lt);
log.warn("Defaulting to Locktype of "+locktypes[locktype]);
}
- }
+ } else
+ log.debug("Defaulting to Locktype of "+locktypes[locktype]);
}
-
+ /**
+ * lock target (blocks until lock is obtained)
+ * @param target
+ * @return lock
+ */
public static Lock getLock(java.io.File target) {
+ return getLock(target, true);
+ }
+ public static Lock getLock(java.io.File target, boolean block) {
if (locktype==0)
- return new FileLock(target);
+ return new FileLock(target, block);
if (locktype==1)
- return new NativeLock(target);
+ return new NativeLock(target, block);
log.fatal("Implementation Error! No valid Locktype value");
return null;
}
+ /**
+ * try to lock target
+ * @param target
+ * @return null if lock was not possible
+ */
+ public static Lock tryLock(File target) {
+ return getLock(target, false);
+ }
}