1 package org.objectweb.celtix.maven_plugin; 2 3 import java.io.IOException ; 4 5 import java.net.MalformedURLException ; 6 import java.net.URL ; 7 import java.util.Enumeration ; 8 import java.util.jar.JarEntry ; 9 import java.util.jar.JarFile ; 10 11 import org.objectweb.celtix.tools.WSDLToJava; 12 13 14 public final class CodegenUtils { 15 16 static long timestamp; 17 18 private CodegenUtils() { 19 } 21 22 public static long getCodegenTimestamp() { 23 if (timestamp != 0) { 24 return timestamp; 25 } 26 27 getClassTime(CodegenUtils.class); 28 getClassTime(WSDLToJava.class); 29 30 31 return timestamp; 32 } 33 34 private static void getClassTime(Class class1) { 35 String str = "/" + class1.getName().replace('.', '/') + ".class"; 36 URL url = class1.getResource(str); 37 if (url != null) { 38 while ("jar".equals(url.getProtocol())) { 39 str = url.getPath(); 40 if (str.lastIndexOf("!") != -1) { 41 str = str.substring(0, str.lastIndexOf("!")); 42 } 43 try { 44 url = new URL (str); 45 } catch (MalformedURLException e) { 46 return; 47 } 48 } 49 JarFile jar; 50 try { 51 jar = new JarFile (url.getPath()); 52 Enumeration entries = jar.entries(); 53 while (entries.hasMoreElements()) { 54 JarEntry entry = (JarEntry )entries.nextElement(); 55 if (!entry.isDirectory() 56 && !entry.getName().startsWith("META") 57 && entry.getTime() > timestamp) { 58 59 timestamp = entry.getTime(); 60 } 61 } 62 } catch (IOException e) { 63 e.printStackTrace(); 65 } 66 } 67 } 68 69 } 70 | Popular Tags |