1 | /* |
2 | * Created on Sep 19, 2004 |
3 | * |
4 | * FIXME To change the template for this generated file go to |
5 | * Window - Preferences - Java - Code Style - Code Templates |
6 | */ |
7 | package biz.xsoftware.manifest; |
8 | |
9 | import java.io.File; |
10 | import java.net.URL; |
11 | import java.util.jar.Attributes; |
12 | import java.util.jar.Manifest; |
13 | import java.util.logging.Logger; |
14 | |
15 | /** |
16 | * @author Dean Hiller |
17 | * |
18 | * FIXME To change the template for this generated type comment go to |
19 | * Window - Preferences - Java - Code Style - Code Templates |
20 | */ |
21 | public class ManifestUtilImpl implements ManifestInfo.ManifestUtil { |
22 | |
23 | private static final Logger log = Logger.getLogger(ManifestUtilImpl.class.getName()); |
24 | |
25 | public File getFile(URL url) { |
26 | log.finest("url="+url); |
27 | String filePart = url.getFile(); |
28 | log.finest("filePart from url="+filePart); |
29 | String nameWithClass = filePart.substring(5, filePart.length()); |
30 | log.finest("nameWithClass="+nameWithClass); |
31 | int index = nameWithClass.indexOf("!"); |
32 | log.finest("index="+index); |
33 | String fileName = nameWithClass.substring(0, index); |
34 | log.finest("fileName of buildtemplate="+fileName); |
35 | |
36 | File f = new File(fileName); |
37 | |
38 | if(!f.exists()) { |
39 | log.warning("Bug, Exiting System. Could not find file="+fileName); |
40 | System.exit(1); |
41 | } |
42 | |
43 | log.finer("returning file="+f.getAbsolutePath()); |
44 | return f; |
45 | } |
46 | |
47 | /* (non-Javadoc) |
48 | * @see biz.xsoftware.manifest.ManifestInfo.SystemInterface#exit(int) |
49 | */ |
50 | public void exit(int code) { |
51 | System.exit(code); |
52 | } |
53 | |
54 | public String getMainClass(Manifest manifest) { |
55 | Attributes attr = manifest.getMainAttributes(); |
56 | String s = attr.getValue("SubMain-Class"); |
57 | return s.trim(); |
58 | } |
59 | |
60 | //dummy main for testing purposes!!! |
61 | public static void main(String[] args) { |
62 | log.fine("just throwing an exception for testing purposes"); |
63 | throw new RuntimeException("Just for testing only"); |
64 | } |
65 | } |