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 2015/09/02 15:17:43 UTC

svn commit: r1700808 - in /myfaces/tobago/branches/tobago-3.0.x: ./ tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ tobago-example/tobago-example-demo/src/main/webapp/ tobago-example/tobago-example-demo/src/main...

Author: lofwyr
Date: Wed Sep  2 13:17:43 2015
New Revision: 1700808

URL: http://svn.apache.org/r1700808
Log:
Merged from trunk
show/test logging configuration

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java
      - copied, changed from r1656507, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml
      - copied, changed from r1656507, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml
Modified:
    myfaces/tobago/branches/tobago-3.0.x/   (props changed)
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml

Propchange: myfaces/tobago/branches/tobago-3.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep  2 13:17:43 2015
@@ -1,3 +1,3 @@
 /myfaces/tobago/branches/tobago-1.5.x:1356585,1357124
 /myfaces/tobago/branches/tobago-tree-table:1226794-1341423
-/myfaces/tobago/trunk:1571193,1571804,1571816,1571941,1571945,1571962,1571966,1576730,1589960,1591854,1600239,1600818,1601860,1602151,1602154,1602343,1604224,1606201,1607642,1609696-1609697,1609718,1610942,1610948,1610970,1610989,1611011,1611259,1611264,1611276,1611329,1611338-1611339,1611571,1613015,1613032,1614827,1614853,1615053,1615114,1615121,1617310,1619789,1621101,1621107,1621134,1621156,1621264,1621282,1621332,1622222,1622243,1622508,1623934,1624033,1625968,1625972,1626270,1628899,1628953,1636842,1636911,1640117,1640147,1640541,1640548,1640638,1640761,1640917,1641575,1641635,1641772,1641775,1641777,1656502,1657180,1657269,1657276,1657279,1658909,1658912,1659026,1659031,1660696,1660699,1660708,1660714,1665486,1665521,1665549,1665569-1665570,1666464,1667304,1667306-1667307,1667309,1668147,1668153,1668249,1675330,1675565,1675584,1675588-1675589,1675636,1676030,1676035,1676038,1679031,1680197,1681981,1682187,1682448,1682545,1682548,1683231,1683306,1683373,1683664,1686204,1687354
 ,1693426,1696720,1698292,1698297,1700742
+/myfaces/tobago/trunk:1571193,1571804,1571816,1571941,1571945,1571962,1571966,1576730,1589960,1591854,1600239,1600818,1601860,1602151,1602154,1602343,1604224,1606201,1607642,1609696-1609697,1609718,1610942,1610948,1610970,1610989,1611011,1611259,1611264,1611276,1611329,1611338-1611339,1611571,1613015,1613032,1614827,1614853,1615053,1615114,1615121,1617310,1619789,1621101,1621107,1621134,1621156,1621264,1621282,1621332,1622222,1622243,1622508,1623934,1624033,1625968,1625972,1626270,1628899,1628953,1636842,1636911,1640117,1640147,1640541,1640548,1640638,1640761,1640917,1641575,1641635,1641772,1641775,1641777,1656502,1656507,1657180,1657269,1657276,1657279,1658343,1658909,1658912,1659026,1659031,1660696,1660699,1660708,1660714,1665486,1665521,1665549,1665569-1665570,1666464,1667304,1667306-1667307,1667309,1668147,1668153,1668249,1675330,1675565,1675584,1675588-1675589,1675636,1676030,1676035,1676038,1679031,1680197,1681981,1682187,1682448,1682545,1682548,1683231,1683306,1683373,1683664
 ,1686204,1687354,1693426,1696720,1698292,1698297,1700742,1700795

Copied: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java (from r1656507, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java?p2=myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java&p1=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java&r1=1656507&r2=1700808&rev=1700808&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/UniversalLoggingInfo.java Wed Sep  2 13:17:43 2015
@@ -1,3 +1,22 @@
+/*
+ * 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.
+ */
+
 package org.apache.myfaces.tobago.example.demo;
 
 import javax.enterprise.context.ApplicationScoped;
@@ -201,45 +220,18 @@ public class UniversalLoggingInfo {
       final Object c = method.invoke(null, category);
 
       if (JUL.equals(id)) {
-//        c.isLoggable(Level.parse(level.toUpperCase()))
-        final Class<?> levelClass = Class.forName("java.util.logging.Level");
-        final Method isLoggable = c.getClass().getMethod("isLoggable", levelClass);
-        final Method parse = levelClass.getMethod("parse", String.class);
-        final Object levelObject = parse.invoke(null, level.toUpperCase());
-        final Object hasLevel = isLoggable.invoke(c, levelObject);
-        return (Boolean) hasLevel;
-      }
-
-      if (SLF4J.equals(id)) {
-        String methodName = "is" + level.substring(0, 1).toUpperCase() + level.substring(1) + "Enabled";
-        final Object hasLevel = c.getClass().getMethod(methodName).invoke(c);
-        return (Boolean) hasLevel;
+        return checkLevelGeneric(level, c, "java.util.logging.Level", "isLoggable", "parse");
       }
 
       if (LOG4J.equals(id)) {
-//        org.apache.log4j.Logger.getLogger("").isEnabledFor(Priority.toPriority("debug"));
-
-        final Class<?> levelClass = Class.forName("org.apache.log4j.Priority");
-        final Method isLoggable = c.getClass().getMethod("isEnabledFor", levelClass);
-        final Method parse = levelClass.getMethod("toPriority", String.class);
-        final Object levelObject = parse.invoke(null, level.toUpperCase());
-        final Object hasLevel = isLoggable.invoke(c, levelObject);
-        return (Boolean) hasLevel;
+        return checkLevelGeneric(level, c, "org.apache.log4j.Priority", "isEnabledFor", "toPriority");
       }
 
       if (LOG4J2.equals(id)) {
-        // org.apache.logging.log4j.core.Logger l = null; l.isEnabled(Level.parse("DEBUG"))
-
-        final Class<?> levelClass = Class.forName("org.apache.logging.log4j.Level");
-        final Method isLoggable = c.getClass().getMethod("isEnabled", levelClass);
-        final Method parse = levelClass.getMethod("getLevel", String.class);
-        final Object levelObject = parse.invoke(null, level.toUpperCase());
-        final Object hasLevel = isLoggable.invoke(c, levelObject);
-        return (Boolean) hasLevel;
+        return checkLevelGeneric(level, c, "org.apache.logging.log4j.Level", "isEnabled", "getLevel");
       }
 
-      if (JCL.equals(id)) {
-        //org.apache.commons.logging.Log l = null; l.isDebugEnabled();
+      if (SLF4J.equals(id) || JCL.equals(id)) {
         String methodName = "is" + level.substring(0, 1).toUpperCase() + level.substring(1) + "Enabled";
         final Object hasLevel = c.getClass().getMethod(methodName).invoke(c);
         return (Boolean) hasLevel;
@@ -247,5 +239,15 @@ public class UniversalLoggingInfo {
 
       throw new IllegalStateException();
     }
+
+    private boolean checkLevelGeneric(String level, Object c, String clazz, String enabledMethod, String levelMethod)
+        throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+      final Class<?> levelClass = Class.forName(clazz);
+      final Method isLoggable = c.getClass().getMethod(enabledMethod, levelClass);
+      final Method parse = levelClass.getMethod(levelMethod, String.class);
+      final Object levelObject = parse.invoke(null, level.toUpperCase());
+      final Object hasLevel = isLoggable.invoke(c, levelObject);
+      return (Boolean) hasLevel;
+    }
   }
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml?rev=1700808&r1=1700807&r2=1700808&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml Wed Sep  2 13:17:43 2015
@@ -71,13 +71,6 @@
     <managed-bean-scope>application</managed-bean-scope>
   </managed-bean>
 
-  <navigation-rule>
-    <navigation-case>
-      <from-outcome>server-info</from-outcome>
-      <to-view-id>/server-info.xhtml</to-view-id>
-    </navigation-case>
-  </navigation-rule>
-
   <!--  overview  -->
 
   <lifecycle>

Copied: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml (from r1656507, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml?p2=myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml&r1=1656507&r2=1700808&rev=1700808&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/logging-info.xhtml Wed Sep  2 13:17:43 2015
@@ -17,27 +17,22 @@
  * limitations under the License.
 -->
 
-<ui:composition template="/WEB-INF/tags/layout/overview.xhtml"
+<ui:composition template="/layout/overview.xhtml"
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:tx="http://myfaces.apache.org/tobago/extension"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:f="http://java.sun.com/jsf/core">
-
   <ui:param name="title" value="Logging Info"/>
 
-  <tc:panel>
+  <tc:panel rendered="#{info.enabled}">
     <f:facet name="layout">
       <tc:gridLayout rows="auto;auto;auto;*"/>
     </f:facet>
 
-    <tc:panel>
-      <f:facet name="layout">
-        <tc:gridLayout columns="*;auto"/>
-      </f:facet>
-
+    <tc:segmentLayout>
       <tx:in label="Test Category" value="#{universalLoggingInfo.testCategory}"/>
       <tc:button label="Update" action="#{universalLoggingInfo.update}"/>
-    </tc:panel>
+    </tc:segmentLayout>
 
     <tc:separator/>
 

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml?rev=1700808&r1=1700807&r2=1700808&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml Wed Sep  2 13:17:43 2015
@@ -51,7 +51,9 @@
                               value="#{overviewBundle.pageTitle} - #{info.version} - #{overviewBundle.tobago_url}"/>
           </tc:command>
           <tc:command link="http://myfaces.apache.org/tobago" label="Tobago in the Web"/>
-          <tc:command action="server-info" immediate="true" label="Server Info" disabled="#{! info.enabled}"/>
+          <tc:command action="/server-info.xhtml" immediate="true" label="Server Info" disabled="#{! info.enabled}"/>
+          <tc:command action="/logging-info.xhtml" immediate="true" label="Logging Info" disabled="#{! info.enabled}"/>
+          <tc:separator/>
           <tc:command label="Sub-Menu" omit="true">
             <tc:command label="Sub 1" omit="true"/>
             <tc:command label="Sub 2" omit="true"/>