added a an axis log4j appender property to the jalview.Cache.
[jalview.git] / src / jalview / bin / Cache.java
index a5231e1..7eaae62 100755 (executable)
@@ -11,16 +11,53 @@ package jalview.bin;
 import java.util.*;\r
 import java.io.*;\r
 \r
+import java.util.jar.*;\r
 public class Cache\r
 {\r
+  public static String  VERSION = "ß test";\r
+  public static String  BUILD_DATE = "1-1-2005";\r
+\r
   public static Properties applicationProperties;\r
   // Current properties include:\r
   //\r
   // LAST_DIRECTORY   , use this to cache record of where the user looked to find a file\r
   // UNIPROT_CACHE\r
+  // USER_DEFINED_COLOUR - file describing last user set colours\r
+  // FONT_NAME\r
+  // FONT_STYLE\r
+  // FONT_SIZE\r
+  // logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services)\r
 \r
   public static void loadProperties()\r
   {\r
+    // get last build time.\r
+    try{\r
+          long date = 0;\r
+\r
+          String localFile = Cache.class.getProtectionDomain().getCodeSource().getLocation().toString();\r
+          localFile = localFile.concat("!/");\r
+          String tmpString = "jar:";\r
+          String localJarFileString = tmpString.concat(localFile);\r
+          java.net.URL localJarFileURL = new java.net.URL(localJarFileString);\r
+          java.net.JarURLConnection localJarFile = (java.net.JarURLConnection)localJarFileURL.openConnection();\r
+\r
+          date = localJarFile.getLastModified();\r
+\r
+          if(date==0)\r
+          {\r
+            // this is called for unpackaged class files.\r
+            // not entirely accurate as it only tells you when Cache.class was last compiled\r
+            java.net.URL url = Cache.class.getResource("/jalview/bin/Cache.class");\r
+            java.io.File f = new java.io.File(url.getFile());\r
+            date = f.lastModified();\r
+          }\r
+\r
+          BUILD_DATE = new Date( date ).toString();\r
+\r
+\r
+    }catch(Exception ex){ex.printStackTrace();}\r
+\r
+\r
     applicationProperties = new Properties();\r
 \r
     try\r
@@ -32,11 +69,7 @@ public class Cache
       in.close();\r
     }\r
     catch (Exception ex)\r
-    {\r
-      ex.printStackTrace();\r
-    }\r
-\r
-\r
+    { }\r
   }\r
 \r
   public static String getProperty(String key)\r
@@ -44,7 +77,7 @@ public class Cache
     return  applicationProperties.getProperty(key);\r
   }\r
 \r
-  public static void setProperty(String key, String obj)\r
+  public static String setProperty(String key, String obj)\r
   {\r
     try\r
     {\r
@@ -59,6 +92,8 @@ public class Cache
     catch (Exception ex)\r
     {}\r
 \r
+    return obj;\r
+\r
   }\r
 \r
 \r