Author: ppitonak(a)redhat.com
Date: 2010-09-01 06:26:09 -0400 (Wed, 01 Sep 2010)
New Revision: 19064
Added:
modules/tests/metamer/trunk/application/src/main/webapp/templates/footer.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/VersionBean.java
modules/tests/metamer/trunk/application/src/main/webapp/index.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/templates/list.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/templates/template.xhtml
Log:
* version of JDK, JSF, operating system and browser added to VersionBean
* footer in templates remade
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/VersionBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/VersionBean.java 2010-09-01
10:23:37 UTC (rev 19063)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/VersionBean.java 2010-09-01
10:26:09 UTC (rev 19064)
@@ -21,11 +21,20 @@
*******************************************************************************/
package org.richfaces.tests.metamer.bean;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
+import java.security.CodeSource;
import java.util.Properties;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
import javax.annotation.PostConstruct;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.log.Logger;
@@ -47,6 +56,7 @@
private String scmRevision;
private String scmTimestamp;
private String fullVersion;
+ private String jsfVersion;
/**
* Initializes the managed bean.
@@ -102,6 +112,61 @@
return fullVersion;
}
+ public String getJavaVersion() {
+ return System.getProperty("java.runtime.name") + " " +
System.getProperty("java.runtime.version");
+ }
+
+ public String getOsVersion() {
+ return System.getProperty("os.name") + " " +
System.getProperty("os.version");
+ }
+
+ public String getJsfVersion() {
+ if (jsfVersion != null) {
+ return jsfVersion;
+ }
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext == null) {
+ return null;
+ }
+
+ Class<?> applicationClass = facesContext.getApplication().getClass();
+ JarInputStream jarInputStream = null;
+
+ try {
+ CodeSource codeSource =
applicationClass.getProtectionDomain().getCodeSource();
+ URL url = codeSource.getLocation();
+ File file = new File(url.getFile());
+ jarInputStream = new JarInputStream(new FileInputStream(file));
+ Manifest manifest = jarInputStream.getManifest();
+
+ if (manifest != null && manifest.getMainAttributes() != null) {
+ jsfVersion =
manifest.getMainAttributes().getValue("Implementation-Title");
+ jsfVersion += " ";
+ jsfVersion +=
manifest.getMainAttributes().getValue("Implementation-Version");
+ } else {
+ jsfVersion = "Unknown version of JSF";
+ }
+ } catch (Exception e) {
+ LOGGER.error(e);
+ } finally {
+ if (jarInputStream != null) {
+ try {
+ jarInputStream.close();
+ } catch (IOException e) {
+ LOGGER.error(e);
+ }
+ }
+ }
+
+ return jsfVersion;
+ }
+
+ public String getBrowserVersion() {
+ HttpServletRequest request = (HttpServletRequest)
FacesContext.getCurrentInstance().getExternalContext().getRequest();
+ return request.getHeader("user-agent");
+ }
+
@Override
public String toString() {
return getFullVersion();
Modified: modules/tests/metamer/trunk/application/src/main/webapp/index.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/index.xhtml 2010-09-01
10:23:37 UTC (rev 19063)
+++ modules/tests/metamer/trunk/application/src/main/webapp/index.xhtml 2010-09-01
10:26:09 UTC (rev 19064)
@@ -22,7 +22,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
-
xmlns:a4j="http://richfaces.org/a4j">
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Metamer: RichFaces Testing Application</title>
@@ -59,11 +60,7 @@
</h:panelGroup>
</h:panelGrid>
- <hr style="width: 1050px; margin-left: 0px;"/>
- #{a4j.version}
- <br/>
- #{metamer.fullVersion}
-
+ <ui:include src="/templates/footer.xhtml" />
</h:form>
</h:body>
</html>
\ No newline at end of file
Added: modules/tests/metamer/trunk/application/src/main/webapp/templates/footer.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/templates/footer.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/templates/footer.xhtml 2010-09-01
10:26:09 UTC (rev 19064)
@@ -0,0 +1,37 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2010, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jsp/jstl/core">
+
+ <hr style="width: 1050px; margin-left: 0px;"/>
+ <ul>
+ <li><h:outputText id="richfacesVersion"
value="#{a4j.version}"/></li>
+ <li><h:outputText id="metamerVersion"
value="#{metamer.fullVersion}"/></li>
+ <li><h:outputText id="javaVersion"
value="#{metamer.javaVersion}"/></li>
+ <li><h:outputText id="osVersion"
value="#{metamer.osVersion}"/></li>
+ <li><h:outputText id="jsfVersion"
value="#{metamer.jsfVersion}"/></li>
+ <li><h:outputText id="browserVersion"
value="#{metamer.browserVersion}"/></li>
+ </ul>
+
+</ui:composition>
\ No newline at end of file
Modified: modules/tests/metamer/trunk/application/src/main/webapp/templates/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/templates/list.xhtml 2010-09-01
10:23:37 UTC (rev 19063)
+++
modules/tests/metamer/trunk/application/src/main/webapp/templates/list.xhtml 2010-09-01
10:26:09 UTC (rev 19064)
@@ -47,9 +47,6 @@
<ui:insert name="links">Insert some links to pages
here</ui:insert>
</h:panelGroup>
- <hr style="width: 900px; margin-left: 0px;"/>
- #{a4j.version}
- <br/>
- #{metamer.fullVersion}
+ <ui:include src="/templates/footer.xhtml" />
</h:body>
</html>
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/templates/template.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/templates/template.xhtml 2010-09-01
10:23:37 UTC (rev 19063)
+++
modules/tests/metamer/trunk/application/src/main/webapp/templates/template.xhtml 2010-09-01
10:26:09 UTC (rev 19064)
@@ -67,10 +67,7 @@
<div class="footer">
<ui:insert name="footer">
- <hr />
- #{a4j.version}
- <br/>
- #{metamer.fullVersion}
+ <ui:include src="/templates/footer.xhtml" />
</ui:insert>
</div>