1 16 package org.apache.juddi.util; 17 18 import java.io.File ; 19 import java.net.JarURLConnection ; 20 import java.net.URL ; 21 import java.text.DateFormat ; 22 import java.util.Date ; 23 24 27 public class Release 28 { 29 private static final String REGISTRY_VERSION = "0.9rc4"; 30 private static final String UDDI_VERSION = "2.0"; 31 32 private Release() 34 { 35 } 36 37 public static String getRegistryVersion() 38 { 39 return REGISTRY_VERSION; 40 } 41 42 public static String getUDDIVersion() 43 { 44 return UDDI_VERSION; 45 } 46 47 public static String getLastModified() 48 { 49 String filePath = getClassFileLocation(Release.class); 50 if (filePath == null) 51 return "Unknown"; 52 53 File file = new File (filePath); 54 long lastMod = file.lastModified(); 55 56 return DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG).format(new Date (lastMod)); 57 } 58 59 67 private static String getClassFileLocation(Class clazz) 68 { 69 URL url = null; 71 try { 72 url = clazz.getProtectionDomain().getCodeSource().getLocation(); 73 if (url == null) 74 return ""; 75 } 76 catch(Throwable t) { 77 return ""; 78 } 79 80 try 81 { 82 String location = url.toString(); 83 if (location.startsWith("jar:file:/")) 84 { 85 File file = new File (url.getFile()); 86 return file.getPath().substring(6); 87 } 88 else if (location.startsWith("jar")) 89 { 90 url = ((JarURLConnection )url.openConnection()).getJarFileURL(); 91 return url.toString(); 92 } 93 else if (location.startsWith("file")) 94 { 95 File file = new File (url.getFile()); 96 return file.getAbsolutePath(); 97 } 98 else 99 { 100 return url.toString(); 101 } 102 } 103 catch (Throwable t) { 104 return null; 105 } 106 } 107 } 108 | Popular Tags |