01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.ioc.internal;
16:
17: import static java.lang.String.format;
18: import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
19:
20: import java.io.InputStream;
21: import java.net.URL;
22: import java.util.Collections;
23: import java.util.Enumeration;
24: import java.util.List;
25: import java.util.Map;
26: import java.util.jar.Attributes;
27: import java.util.jar.Manifest;
28:
29: public class ReadManifest {
30:
31: /**
32: * @param args
33: */
34: public static void main(String[] args) throws Exception {
35: ClassLoader loader = ReadManifest.class.getClassLoader();
36:
37: Enumeration<URL> urls = loader
38: .getResources("META-INF/MANIFEST.MF");
39:
40: while (urls.hasMoreElements()) {
41: URL url = urls.nextElement();
42:
43: System.out.println(url);
44:
45: InputStream is = url.openStream();
46:
47: Manifest mf = new Manifest(is);
48:
49: is.close();
50:
51: printManifest(mf);
52: }
53:
54: }
55:
56: static void printManifest(Manifest mf) {
57:
58: printAttributes(mf.getMainAttributes());
59:
60: if (false) {
61: Map<String, Attributes> entries = mf.getEntries();
62: List<String> keys = newList(entries.keySet());
63: Collections.sort(keys);
64:
65: for (String key : keys) {
66: System.out.println(format(" %s", key));
67:
68: Attributes a = entries.get(key);
69:
70: printAttributes(a);
71:
72: }
73: }
74: }
75:
76: private static void printAttributes(Attributes a) {
77: for (Object key : a.keySet()) {
78: Object value = a.get(key);
79:
80: System.out.println(format(" %30s: %s", key, value));
81: }
82:
83: }
84: }
|