You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/11/20 13:16:29 UTC
svn commit: r1411636 - in
/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main:
java/org/apache/myfaces/tobago/example/demo/ webapp/
Author: lofwyr
Date: Tue Nov 20 12:16:28 2012
New Revision: 1411636
URL: http://svn.apache.org/viewvc?rev=1411636&view=rev
Log:
Demo: better visualisation of the MANIFEST.MF content.
Modified:
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestEntry.java
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestEntry.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestEntry.java?rev=1411636&r1=1411635&r2=1411636&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestEntry.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestEntry.java Tue Nov 20 12:16:28 2012
@@ -19,28 +19,26 @@
package org.apache.myfaces.tobago.example.demo;
-public class ManifestEntry {
- private String url;
- private String content;
+import org.apache.myfaces.tobago.context.Markup;
- public ManifestEntry(String url, String content) {
- this.url = url;
- this.content = content;
- }
+public class ManifestEntry {
+ private final String name;
+ private final String value;
- public String getUrl() {
- return url;
+ public ManifestEntry(String name, String value) {
+ this.name = name;
+ this.value = value;
}
- public void setUrl(String url) {
- this.url = url;
+ public String getName() {
+ return name;
}
- public String getContent() {
- return content;
+ public String getValue() {
+ return value;
}
- public void setContent(String content) {
- this.content = content;
+ public Markup getMarkup() {
+ return value == null ? Markup.STRONG : Markup.NULL;
}
}
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java?rev=1411636&r1=1411635&r2=1411636&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java Tue Nov 20 12:16:28 2012
@@ -22,52 +22,52 @@ package org.apache.myfaces.tobago.exampl
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.BufferedReader;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
-import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+@ApplicationScoped
+@Named
public class ManifestReader {
private static final Logger LOG = LoggerFactory.getLogger(ManifestReader.class);
- private List<ManifestEntry> manifestList = new ArrayList<ManifestEntry>();
+ private final List<ManifestEntry> manifestList;
- public ManifestReader(){
+ public ManifestReader() {
+
+ manifestList = new ArrayList<ManifestEntry>();
+
+ URL url = null;
try {
Enumeration<URL> ul = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
- String line;
- StringBuilder content;
- BufferedReader in;
- URL url;
while (ul.hasMoreElements()) {
url = ul.nextElement();
- in = new BufferedReader(new InputStreamReader(url.openStream()));
- content = new StringBuilder();
- Map.Entry<String, String> e;
- while((line= in.readLine()) != null){
- content.append(line+"\r\n");
+ String name = url.toString();
+ name = name.replaceAll(".+/([^/]+\\.jar)\\!/META-INF/MANIFEST.MF", "$1");
+ final ManifestEntry jar = new ManifestEntry(name, null);
+ manifestList.add(jar);
+
+ final Manifest manifest = new Manifest(url.openStream());
+ final Attributes attributes = manifest.getMainAttributes();
+ for (Object key : attributes.keySet()) {
+ manifestList.add(new ManifestEntry("Â Â Â Â Â " + key.toString(), attributes.get(key).toString()));
}
- in.close();
-
- manifestList.add(new ManifestEntry(url.toString(), content.toString()));
}
} catch (IOException e) {
- LOG.error("", e);
+ LOG.error("Problem while processing URL: " + url, e);
}
}
public List<ManifestEntry> getManifestList() {
return manifestList;
}
-
- public void setManifestList(List<ManifestEntry> manifestList) {
- this.manifestList = manifestList;
- }
}
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml?rev=1411636&r1=1411635&r2=1411636&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml Tue Nov 20 12:16:28 2012
@@ -91,22 +91,14 @@
</tc:sheet>
</tc:panel>
- <tc:panel>
- <f:facet name="layout">
- <tc:gridLayout columns="auto;*"/>
- </f:facet>
-
- <tc:label value="Manifest"/>
-
- <tc:sheet value="#{manifestReader.manifestList}" var="manifest">
- <tc:column label="URL">
- <tc:out value="#{manifest.url}"/>
- </tc:column>
- <tc:column label="Content">
- <tc:out value="#{manifest.content}"/>
- </tc:column>
- </tc:sheet>
- </tc:panel>
+ <tc:sheet value="#{manifestReader.manifestList}" var="manifest">
+ <tc:column label="Library/Key">
+ <tc:out value="#{manifest.name}" markup="#{manifest.markup}"/>
+ </tc:column>
+ <tc:column label="Value">
+ <tc:out value="#{manifest.value}"/>
+ </tc:column>
+ </tc:sheet>
</tc:panel>
</ui:composition>