1 19 20 package org.lucane.common; 21 22 import java.io.IOException ; 23 import java.util.jar.Attributes ; 24 import java.util.jar.JarFile ; 25 26 29 public class JarUtils 30 { 31 38 private static String getManifestAttribute(String jarUrl, String attribute) 39 throws IOException 40 { 41 JarFile jar = new JarFile (jarUrl); 42 Attributes attr = jar.getManifest().getMainAttributes(); 43 String value = attr.getValue(attribute); 44 45 jar.close(); 46 return value; 47 } 48 49 55 public static String getServiceClass(String jarUrl) 56 throws IOException 57 { 58 return getManifestAttribute(jarUrl, "Service-Class"); 59 } 60 61 67 public static String getPluginClass(String jarUrl) 68 throws IOException 69 { 70 return getManifestAttribute(jarUrl, "Plugin-Class"); 71 } 72 73 79 public static boolean isWebEnabled(String jarUrl) 80 throws IOException 81 { 82 return Boolean.valueOf(getManifestAttribute(jarUrl, "Web-Enabled")).booleanValue(); 83 } 84 } | Popular Tags |