1 package org.objectweb.celtix.version; 2 3 import java.io.*; 4 import java.util.*; 5 6 public final class Version { 7 8 private static String version; 9 10 private static final String VERSION_BASE = "/org/objectweb/celtix/version/"; 11 12 private Version() { 13 } 15 16 private static InputStream getResourceAsStream(String resource) { 17 ClassLoader cl = Version.class.getClassLoader(); 18 InputStream ins = cl.getResourceAsStream(resource); 19 if (ins == null && resource.startsWith("/")) { 20 ins = cl.getResourceAsStream(resource.substring(1)); 21 } 22 return ins; 23 } 24 25 private static synchronized void loadProperties() { 26 if (version == null) { 27 Properties p = new Properties(); 28 29 try { 30 InputStream ins = getResourceAsStream(VERSION_BASE + "version.properties"); 31 32 p.load(ins); 33 ins.close(); 34 } catch (IOException ex) { 35 } 37 38 version = p.getProperty("product.version"); 39 } 40 } 41 42 public static String getCurrentVersion() { 43 loadProperties(); 44 return version; 45 } 46 47 48 52 public static String getCompleteVersionString() { 53 return getCurrentVersion(); 54 } 55 } 56 | Popular Tags |