applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / client / simpleclient / LockFactory.java
index d8098d7..a392db2 100644 (file)
@@ -1,52 +1,81 @@
-package uk.ac.vamsas.client.simpleclient;
-
-import java.io.File;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class LockFactory {
-  protected static Log log = LogFactory.getLog(LockFactory.class);
-  public static int locktype=0; // use file lock by default
-  public static String[] locktypes = {"file","native"};
-  {
-    String lockt = System.getProperty("vamsas.locktype");
-    if (lockt!=null) {
-      int i,j;
-      for (i=0, j=locktypes.length; i<j && locktypes[i].equalsIgnoreCase(lockt); i++)
-        ;
-      if (i>=j) {
-        String lt = "'"+locktypes[0]+"'";
-        for (i=1; i<j; i++)
-          lt += ",'"+locktypes[i]+"'";
-        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, block);
-    if (locktype==1)
-      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);
-  }
-}
+/*\r
+ * This file is part of the Vamsas Client version 0.1. \r
+ * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, \r
+ *  Andrew Waterhouse and Dominik Lindner.\r
+ * \r
+ * Earlier versions have also been incorporated into Jalview version 2.4 \r
+ * since 2008, and TOPALi version 2 since 2007.\r
+ * \r
+ * The Vamsas Client is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU Lesser General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *  \r
+ * The Vamsas Client is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU Lesser General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU Lesser General Public License\r
+ * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package uk.ac.vamsas.client.simpleclient;\r
+\r
+import java.io.File;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+public class LockFactory {\r
+  protected static Log log = LogFactory.getLog(LockFactory.class);\r
+\r
+  public static int locktype = 0; // use file lock by default\r
+\r
+  public static String[] locktypes = { "file", "native" };\r
+  {\r
+    String lockt = System.getProperty("vamsas.locktype");\r
+    if (lockt != null) {\r
+      int i, j;\r
+      for (i = 0, j = locktypes.length; i < j\r
+          && locktypes[i].equalsIgnoreCase(lockt); i++)\r
+        ;\r
+      if (i >= j) {\r
+        String lt = "'" + locktypes[0] + "'";\r
+        for (i = 1; i < j; i++)\r
+          lt += ",'" + locktypes[i] + "'";\r
+        log.warn("System property vamsas.locktype takes one of " + lt);\r
+        log.warn("Defaulting to Locktype of " + locktypes[locktype]);\r
+      }\r
+    } else\r
+      log.debug("Defaulting to Locktype of " + locktypes[locktype]);\r
+  }\r
+\r
+  /**\r
+   * lock target (blocks until lock is obtained)\r
+   * \r
+   * @param target\r
+   * @return lock\r
+   */\r
+  public static Lock getLock(java.io.File target) {\r
+    return getLock(target, true);\r
+  }\r
+\r
+  public static Lock getLock(java.io.File target, boolean block) {\r
+    if (locktype == 0)\r
+      return new FileLock(target, block);\r
+    if (locktype == 1)\r
+      return new NativeLock(target, block);\r
+    log.fatal("Implementation Error! No valid Locktype value");\r
+    return null;\r
+  }\r
+\r
+  /**\r
+   * try to lock target\r
+   * \r
+   * @param target\r
+   * @return null if lock was not possible\r
+   */\r
+  public static Lock tryLock(File target) {\r
+    return getLock(target, false);\r
+  }\r
+}\r