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 2007/02/19 11:27:25 UTC

svn commit: r509146 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/ example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/ example/demo/src/main/webapp/ example/demo/src/main/webapp/WEB-INF/

Author: lofwyr
Date: Mon Feb 19 02:27:24 2007
New Revision: 509146

URL: http://svn.apache.org/viewvc?view=rev&rev=509146
Log:
Display some information about the server.

Added:
    myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/ServerInfo.java
    myfaces/tobago/trunk/example/demo/src/main/webapp/server-info.jsp
Removed:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoVersion.java
Modified:
    myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java
    myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/tobago/trunk/example/demo/src/main/webapp/menu.jsp

Modified: myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java?view=diff&rev=509146&r1=509145&r2=509146
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java (original)
+++ myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java Mon Feb 19 02:27:24 2007
@@ -87,7 +87,7 @@
     while (enumeration.hasMoreElements()) {
       DefaultMutableTreeNode maybeMarker = ((DefaultMutableTreeNode) enumeration.nextElement());
       Node node = (Node) maybeMarker.getUserObject();
-      if (viewId.contains(node.getOutcome())) {
+      if (node.getOutcome() != null && viewId.contains(node.getOutcome())) {
         state.setMarker(maybeMarker);
         break;
       }

Added: myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/ServerInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/ServerInfo.java?view=auto&rev=509146
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/ServerInfo.java (added)
+++ myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/ServerInfo.java Mon Feb 19 02:27:24 2007
@@ -0,0 +1,84 @@
+package org.apache.myfaces.tobago.example.demo;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+import java.util.Properties;
+import java.io.InputStream;
+import java.io.IOException;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class ServerInfo {
+
+  private static final Log LOG = LogFactory.getLog(ServerInfo.class);
+
+  private String version;
+
+  private boolean enabled;
+
+  public ServerInfo() {
+    InputStream pom = null;
+    try {
+      pom = getClass().getClassLoader().getResourceAsStream(
+          "META-INF/maven/org.apache.myfaces.tobago/tobago-core/pom.properties");
+      Properties properties = new Properties();
+      properties.load(pom);
+      version = properties.getProperty("version");
+    } catch (IOException e) {
+      LOG.warn("No version info found.", e);
+    } finally {
+      IOUtils.closeQuietly(pom);
+    }
+  }
+
+  public String getServerInfo() {
+    if (enabled) {
+      return ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getServerInfo();
+    } else {
+      return null;
+    }
+  }
+
+  public Properties getSystemProperties() {
+    if (enabled) {
+      return System.getProperties();
+    } else {
+      return null;
+    }
+  }
+
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+  public boolean isEnabled() {
+    return enabled;
+  }
+
+  public void setEnabled(boolean enabled) {
+    this.enabled = enabled;
+  }
+}

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=509146&r1=509145&r2=509146
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml Mon Feb 19 02:27:24 2007
@@ -48,12 +48,6 @@
     <managed-bean-scope>session</managed-bean-scope>
   </managed-bean>
 
-  <managed-bean>
-    <managed-bean-name>tobagoVersion</managed-bean-name>
-    <managed-bean-class>org.apache.myfaces.tobago.TobagoVersion</managed-bean-class>
-    <managed-bean-scope>application</managed-bean-scope>
-  </managed-bean>
-
   <lifecycle>
     <phase-listener>
       org.apache.myfaces.tobago.example.demo.SynchronizeNavigationPhaseListener
@@ -63,12 +57,31 @@
     </phase-listener>
   </lifecycle>
 
-
   <managed-bean>
     <managed-bean-name>navigation</managed-bean-name>
     <managed-bean-class>org.apache.myfaces.tobago.example.demo.Navigation</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+
+  <managed-bean>
+    <managed-bean-name>info</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.tobago.example.demo.ServerInfo</managed-bean-class>
     <managed-bean-scope>application</managed-bean-scope>
+    <managed-property>
+      <description>Enabled the Server Info. May be disabled for security reasons.</description>
+      <property-name>enabled</property-name>
+      <property-class>boolean</property-class>
+      <value>false</value>
+      <!--<value>true</value>-->
+    </managed-property>
   </managed-bean>
+
+  <navigation-rule>
+    <navigation-case>
+      <from-outcome>server-info</from-outcome>
+      <to-view-id>/server-info.jsp</to-view-id>
+    </navigation-case>
+  </navigation-rule>
 
   <!--  overview  -->
 

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/menu.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/menu.jsp?view=diff&rev=509146&r1=509145&r2=509146
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/menu.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/menu.jsp Mon Feb 19 02:27:24 2007
@@ -44,11 +44,14 @@
           </tc:menu>
 
           <tc:menu label="#{overviewBundle.menu_help}">
-            <tc:menuItem onclick="alert('#{overviewBundle.pageTitle}' + String.fromCharCode(10) + '#{tobagoVersion.name}' + String.fromCharCode(10) + '#{overviewBundle.tobago_url}' + String.fromCharCode(10))"
+            <tc:menuItem onclick="alert('#{overviewBundle.pageTitle}' + String.fromCharCode(10) + '#{info.version}' + String.fromCharCode(10) + '#{overviewBundle.tobago_url}' + String.fromCharCode(10))"
                          label="#{overviewBundle.menu_about}" />
             <tc:menuItem onclick="LOG.show();"
                          label="#{overviewBundle.menu_showLog}"
                          rendered="#{clientConfigController.debugMode}"/>
+            <tc:menuItem action="server-info"
+                         label="Server Info"
+                         disabled="#{! info.enabled}"/>
           </tc:menu>
         </tc:menuBar>
 

Added: myfaces/tobago/trunk/example/demo/src/main/webapp/server-info.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/server-info.jsp?view=auto&rev=509146
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/server-info.jsp (added)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/server-info.jsp Mon Feb 19 02:27:24 2007
@@ -0,0 +1,45 @@
+<%--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+--%>
+<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
+<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>
+
+<layout:overview>
+  <jsp:body>
+    <tc:box label="Server Info">
+      <f:facet name="layout">
+        <tc:gridLayout rows="fixed;fixed;fixed;fixed;*" />
+      </f:facet>
+
+      <tx:in value="#{info.version}" readonly="true"
+          label="Tobago Version" />
+
+      <tx:in value="#{info.serverInfo}" readonly="true"
+          label="Server Info" />
+
+      <tx:in value="#{info.systemProperties['java.runtime.version']} - #{info.systemProperties['java.vm.vendor']}" readonly="true"
+          label="Java" />
+
+      <tx:in value="#{info.systemProperties['os.name']} - #{info.systemProperties['os.version']} - #{info.systemProperties['os.arch']}" readonly="true"
+          label="Operating System" />
+
+      <tc:cell/>
+
+    </tc:box>
+  </jsp:body>
+</layout:overview>