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 2017/09/28 12:18:04 UTC

[myfaces-tobago] 01/02: demo: show tobago build time in server-info

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 0a3a3b971429ee423001345372f2f083fbdbaec1
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu Sep 28 13:42:20 2017 +0200

    demo: show tobago build time in server-info
---
 pom.xml                                            |  1 +
 .../tobago/example/demo/ManifestReader.java        | 20 ++++++++++++++++++
 .../src/main/webapp/server-info.xhtml              | 24 ++++++++++------------
 3 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/pom.xml b/pom.xml
index e431f1c..e636c9a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -748,6 +748,7 @@
               </manifest>
               <manifestEntries>
                 <Revision>${scm.revision}</Revision>
+                <Build-Time>${maven.build.timestamp}</Build-Time>
               </manifestEntries>
               <manifestSections>
                 <manifestSection>
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java
index dcf9ce5..4be7c77 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ManifestReader.java
@@ -28,7 +28,12 @@ import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Named;
 import java.io.IOException;
 import java.net.URL;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.Enumeration;
+import java.util.TimeZone;
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
@@ -42,6 +47,8 @@ public class ManifestReader {
 
   private final SheetState state;
 
+  private Date buildTime;
+
   public ManifestReader() {
 
     state = new SheetState();
@@ -65,6 +72,15 @@ public class ManifestReader {
         for (final Object key : attributes.keySet()) {
           jar.add(new ManifestEntry(key.toString(), attributes.get(key).toString()));
         }
+        if (name.startsWith("tobago-core")) {
+          final DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+          format.setTimeZone(TimeZone.getTimeZone("UTC"));
+          try {
+            buildTime = format.parse(attributes.getValue("Build-Time"));
+          } catch (ParseException e) {
+            LOG.error("Can't parse '" + attributes.getValue("Build-Time") + "'", e);
+          }
+        }
       }
     } catch (final IOException e) {
       LOG.error("Problem while processing URL: " + url, e);
@@ -78,4 +94,8 @@ public class ManifestReader {
   public SheetState getState() {
     return state;
   }
+
+  public Date getBuildTime() {
+    return buildTime;
+  }
 }
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml
index d5f6752..05fb690 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/server-info.xhtml
@@ -19,7 +19,7 @@
 
 <ui:composition template="/main.xhtml"
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
-                xmlns:ui="http://java.sun.com/jsf/facelets">
+                xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core">
 
   <ui:param name="title" value="Server Info"/>
 
@@ -27,26 +27,24 @@
 
     <tc:section label="Main Properties">
 
-      <tc:in value="#{info.version}" readonly="true"
-             label="Tobago Version"/>
+      <tc:in value="#{info.version}" readonly="true" label="Tobago Version"/>
 
-      <tc:in value="#{info.jsfTitle}" readonly="true"
-             label="JSF Implementation"/>
+      <tc:in value="#{manifestReader.buildTime}" readonly="true" label="Tobago Build Time">
+        <f:convertDateTime type="both" />
+      </tc:in>
 
-      <tc:in value="#{info.jsfVersion}" readonly="true"
-             label="JSF Version"/>
+      <tc:in value="#{info.jsfTitle}" readonly="true" label="JSF Implementation"/>
 
-      <tc:in value="#{info.serverInfo}" readonly="true"
-             label="Server Info"/>
+      <tc:in value="#{info.jsfVersion}" readonly="true" label="JSF Version"/>
+
+      <tc:in value="#{info.serverInfo}" readonly="true" label="Server Info"/>
 
       <tc:in value="#{info.systemProperties['java.runtime.version']} - #{info.systemProperties['java.vm.vendor']}"
-             readonly="true"
-             label="Java"/>
+             readonly="true" label="Java"/>
 
       <tc:in
           value="#{info.systemProperties['os.name']} - #{info.systemProperties['os.version']} - #{info.systemProperties['os.arch']}"
-          readonly="true"
-          label="Operating System"/>
+          readonly="true" label="Operating System"/>
 
     </tc:section>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.