1 16 package org.directwebremoting.util; 17 18 import java.io.InputStream ; 19 import java.util.Properties ; 20 21 25 public class VersionUtil 26 { 27 31 public static String getSourceControlInfo() 32 { 33 synchronized (propLock) 34 { 35 if (props == null) 36 { 37 loadProperties(); 38 } 39 40 return props.getProperty(KEY_SCCINFO); 41 } 42 } 43 44 48 public static String getVersion() 49 { 50 synchronized (propLock) 51 { 52 if (props == null) 53 { 54 loadProperties(); 55 } 56 57 return props.getProperty(KEY_VERSION); 58 } 59 } 60 61 64 private static void loadProperties() 65 { 66 synchronized (propLock) 67 { 68 props = new Properties (); 69 70 try 71 { 72 InputStream in = VersionUtil.class.getResourceAsStream(FILENAME_VERSION); 73 props.load(in); 74 } 75 catch (Exception ex) 76 { 77 props.put(KEY_VERSION, VALUE_UNKNOWN); 78 props.put(KEY_SCCINFO, VALUE_UNKNOWN); 79 props.put(KEY_ERROR, ex.toString()); 80 } 81 } 82 } 83 84 private static Properties props = null; 85 86 private static final Object propLock = new Object (); 87 88 private static final String FILENAME_VERSION = "/dwr-version.properties"; 89 90 private static final String KEY_VERSION = "version"; 91 92 private static final String KEY_SCCINFO = "scc-info"; 93 94 private static final String KEY_ERROR = "error"; 95 96 private static final String VALUE_UNKNOWN = "unknown"; 97 } 98 | Popular Tags |