[jboss-cvs] JBossAS SVN: r86861 - in trunk: testsuite/imports/sections and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 6 13:14:23 EDT 2009


Author: stan.silvert at jboss.com
Date: 2009-04-06 13:14:23 -0400 (Mon, 06 Apr 2009)
New Revision: 86861

Removed:
   trunk/testsuite/src/main/org/jboss/test/jsf/webapp/LoggingTest.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/Log4JConversionFilter.java
Modified:
   trunk/component-matrix/pom.xml
   trunk/testsuite/imports/sections/jsf.xml
   trunk/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java
   trunk/testsuite/src/resources/web/WEB-INF/jsftest-web.xml
   trunk/testsuite/src/resources/web/html/jsftest/index.jsp
   trunk/thirdparty/pom.xml
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java
Log:
JBAS-6580 Remove JSF logging bridge and update JSFIntegrationUnitTestCase 


Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/component-matrix/pom.xml	2009-04-06 17:14:23 UTC (rev 86861)
@@ -404,12 +404,6 @@
       </dependency>
       
       <dependency>
-        <groupId>com.sun.facelets</groupId>
-        <artifactId>jsf-facelets</artifactId>
-        <version>1.1.15.B1</version>
-      </dependency>
-      
-      <dependency>
         <groupId>dom4j</groupId>
         <artifactId>dom4j</artifactId>
         <version>1.6.1</version>

Modified: trunk/testsuite/imports/sections/jsf.xml
===================================================================
--- trunk/testsuite/imports/sections/jsf.xml	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/testsuite/imports/sections/jsf.xml	2009-04-06 17:14:23 UTC (rev 86861)
@@ -18,26 +18,6 @@
        </webinf>
      </war>
 
-     <!-- make WAR for testing Facelets logging -->
-     <war destfile="${build.lib}/jbosstest-jsf-facelets.war"
-       webxml="${build.resources}/web/WEB-INF/jsftest-web.xml">
-       <fileset dir="${build.resources}/web/html/jsftest">
-         <include name="**/*.jsp"/>
-       </fileset>
-
-       <classes dir="${build.classes}">
-          <include name="org/jboss/test/jsf/webapp/**"/>
-       </classes>
-
-       <lib dir="${com.sun.facelets.lib}">
-          <include name="jsf-facelets.jar"/>
-       </lib>
-       
-       <webinf dir="${build.resources}/web/html/jsftest/WEB-INF">
-         <include name="**/*"/>
-       </webinf>
-     </war>
-     
      <!-- make WAR for testing legacy WARs that bundle MyFaces -->
      <war destfile="${build.lib}/bundled-myfaces-hellojsf.war"
        webxml="${build.resources}/web/WEB-INF/bundled-myfaces-jsf.xml">

Deleted: trunk/testsuite/src/main/org/jboss/test/jsf/webapp/LoggingTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jsf/webapp/LoggingTest.java	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/testsuite/src/main/org/jboss/test/jsf/webapp/LoggingTest.java	2009-04-06 17:14:23 UTC (rev 86861)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.jboss.test.jsf.webapp;
-
-import com.sun.faces.util.FacesLogger;
-import org.apache.log4j.*;
-import java.io.ByteArrayOutputStream;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-
-/**
- * This class simulates the kind of logging that the JSF implementation
- * does.  It also simulates logging through the Facelets loggers.
- *
- * @author Stan Silvert
- */
-public class LoggingTest {
-    
-   private ByteArrayOutputStream out = new ByteArrayOutputStream();
-
-   /**
-    * Constructor sets up an in-memory Log4J appender.  Log messages
-    * logged with the java.util.logging package should end up in this
-    * appender.
-    */
-   public LoggingTest()
-   {
-      Appender appender = new WriterAppender(new SimpleLayout(), out);
-      Logger log4jLogger = Logger.getLogger("javax.enterprise.resource.webcontainer.jsf");
-      log4jLogger.addAppender(appender);
-      Logger faceletsLogger = Logger.getLogger("facelets");
-      faceletsLogger.addAppender(appender);
-   }
-
-   /**
-    * Send java.util.logging messages using the same java.util Loggers
-    * that the JSF impl uses.
-    * 
-    * During the JUnit test, levels are set on the loggers so that
-    * some messages will pass thorough to log4j and 
-    * captured by the WriterAppender.  Others will not.
-    */
-   public void sendLogMessages()
-   {
-      java.util.logging.Logger julLogger = FacesLogger.RENDERKIT.getLogger();
-      if (julLogger.isLoggable(java.util.logging.Level.SEVERE)) 
-         throw new RuntimeException(julLogger.getName() + " should not be loggable for SEVERE.");
-      julLogger.severe("Logged SEVERE message in RENDERKIT_LOGGER<br/>"); // not logged 
-
-      julLogger = FacesLogger.TAGLIB.getLogger();
-      julLogger.severe("Logged SEVERE message in TAGLIB_LOGGER<br/>"); // not logged
-
-      julLogger = FacesLogger.APPLICATION.getLogger();
-      julLogger.severe("Logged SEVERE message in APPLICATION_LOGGER<br/>"); // logged
-      if (julLogger.isLoggable(java.util.logging.Level.WARNING)) 
-         throw new RuntimeException(julLogger.getName() + " should not be loggable for WARNING.");
-      julLogger.warning("Logged WARNING message in APPLICATION_LOGGER<br/>"); // not logged
-
-      julLogger = FacesLogger.CONTEXT.getLogger();
-      julLogger.warning("Logged WARNING message in CONTEXT_LOGGER<br/>"); // logged
-      if (julLogger.isLoggable(java.util.logging.Level.INFO)) 
-         throw new RuntimeException(julLogger.getName() + " should not be loggable for INFO.");
-      julLogger.info("Logged INFO message in CONTEXT_LOGGER<br/>"); // not logged
-
-      julLogger = FacesLogger.CONFIG.getLogger();
-      julLogger.info("Logged INFO message in CONFIG_LOGGER<br/>"); // logged 
-      if (julLogger.isLoggable(java.util.logging.Level.FINE)) 
-         throw new RuntimeException(julLogger.getName() + " should not be loggable for FINE.");
-      julLogger.fine("Logged FINE message in CONFIG_LOGGER<br/>"); // not logged
-
-      julLogger = FacesLogger.LIFECYCLE.getLogger();
-      julLogger.fine("Logged FINE message in LIFECYCLE_LOGGER<br/>"); // logged
-      if (julLogger.isLoggable(java.util.logging.Level.FINER)) 
-         throw new RuntimeException(julLogger.getName() + " should not be loggable for FINER.");
-      julLogger.finer("Logged FINER message in LIFECYCLE_LOGGER<br/>"); // not logged
-      if (julLogger.isLoggable(java.util.logging.Level.FINEST)) 
-         throw new RuntimeException(julLogger.getName() + " should not be loggable for FINEST.");
-      julLogger.finest("Logged FINER message in LIFECYCLE_LOGGER<br/>"); // not logged
-
-      julLogger = FacesLogger.TIMING.getLogger();
-      julLogger.finer("Logged FINER message in TIMING_LOGGER<br/>"); // logged
-      julLogger.finest("Logged FINEST message in TIMING_LOGGER<br/>"); // logged
-
-      julLogger = FacesLogger.MANAGEDBEAN.getLogger();
-      julLogger.finest("Logged FINEST message in MANAGEDBEAN_LOGGER Logger<br/>"); // logged
-      
-      sendFaceletsLogMessages();
-   }
-   
-   private void sendFaceletsLogMessages()
-   {
-      for (Iterator loggers = loadLoggers(); loggers.hasNext();)
-      {
-         java.util.logging.Logger julLogger = (java.util.logging.Logger)loggers.next();
-         julLogger.info("Here is a message for " + julLogger.getName() + "<br/>");
-      }
-   }
-   
-   // Loading FaceletsLoggers by reflection is much easier than trying to
-   // figure out how to link jboss-faces.jar with the testsuite build.
-   private Iterator loadLoggers()
-   {
-      try
-      {
-         Class faceletsLoggersClass = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.web.jsf.integration.config.FaceletsLoggers");
-         Method method = faceletsLoggersClass.getMethod("getLoggers", null);
-         return (Iterator)method.invoke(null, null);
-      }
-      catch (Exception e)
-      {
-         throw new IllegalStateException("Unable to call FaceletsLoggers.getLoggers()", e);
-      }
-   }
-
-   /**
-    * Return the contents of the in-memory Log4J appender.
-    */
-   public String getLoggedMessages()
-   {
-      return out.toString();
-   }
-}

Modified: trunk/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java	2009-04-06 17:14:23 UTC (rev 86861)
@@ -54,33 +54,7 @@
  */
 public class JSFIntegrationUnitTestCase extends JBossTestCase
 {
-   // Call Log4jService to set logging levels for the JSF impl before the WAR
-   // is deployed
-   public static void setLoggingLevels() throws Exception
-   {
-      HttpClient client = new HttpClient();
-      client.executeMethod(new GetMethod(makeSetLoggerCmd(FacesLogger.MANAGEDBEAN.getLoggerName(), "ALL")));
-      client.executeMethod(new GetMethod(makeSetLoggerCmd(FacesLogger.TAGLIB.getLoggerName(), "FATAL")));
-      client.executeMethod(new GetMethod(makeSetLoggerCmd(FacesLogger.APPLICATION.getLoggerName(), "ERROR")));
-      client.executeMethod(new GetMethod(makeSetLoggerCmd(FacesLogger.CONTEXT.getLoggerName(), "WARN")));
-      client.executeMethod(new GetMethod(makeSetLoggerCmd(FacesLogger.CONFIG.getLoggerName(), "INFO")));
-      client.executeMethod(new GetMethod(makeSetLoggerCmd(FacesLogger.LIFECYCLE.getLoggerName(), "DEBUG")));
-      client.executeMethod(new GetMethod(makeSetLoggerCmd(FacesLogger.TIMING.getLoggerName(), "TRACE")));
-      client.executeMethod(new GetMethod(makeSetLoggerCmd(FacesLogger.RENDERKIT.getLoggerName(), "OFF")));
-   }
 
-   private static String makeSetLoggerCmd(String log4jLogger, String log4jPriority)
-   {
-      String baseURL = HttpUtils.getBaseURL();
-      return baseURL + 
-             "jmx-console/HtmlAdaptor?" +
-             "action=invokeOp&" +
-             "name=jboss.system:type=Log4jService,service=Logging&" +
-             "methodIndex=1&" +
-             "arg0=" + log4jLogger + "&" +
-             "arg1=" + log4jPriority;
-   }
-
    public JSFIntegrationUnitTestCase(String name)
    {
       super(name);
@@ -104,39 +78,7 @@
       // Tests enum support 
       assertTrue(contains(responseBody, "JBoss Color selection is PURPLE"));
 
-      // Test logging
-      assertFalse(contains(responseBody, "Logged SEVERE message in RENDERKIT_LOGGER"));
-      assertFalse(contains(responseBody, "Logged SEVERE message in TAGLIB_LOGGER"));
-      assertTrue(contains(responseBody, "Logged SEVERE message in APPLICATION_LOGGER"));
-      assertFalse(contains(responseBody, "Logged WARNING message in APPLICATION_LOGGER"));
-      assertTrue(contains(responseBody, "Logged WARNING message in CONTEXT_LOGGER"));
-      assertFalse(contains(responseBody, "Logged INFO message in CONTEXT_LOGGER"));
-      assertTrue(contains(responseBody, "Logged INFO message in CONFIG_LOGGER"));
-      assertFalse(contains(responseBody, "Logged FINE message in CONFIG_LOGGER"));
-      assertTrue(contains(responseBody, "Logged FINE message in LIFECYCLE_LOGGER"));
-      assertFalse(contains(responseBody, "Logged FINER message in LIFECYCLE_LOGGER"));
-      assertFalse(contains(responseBody, "Logged FINEST message in LIFECYCLE_LOGGER"));
-      assertTrue(contains(responseBody, "Logged FINER message in TIMING_LOGGER"));
-      assertTrue(contains(responseBody, "Logged FINEST message in TIMING_LOGGER"));
-      assertTrue(contains(responseBody, "Logged FINEST message in MANAGEDBEAN_LOGGER"));
-      
    }   
-   
-   public void testNoFaceletsLogging() throws Exception 
-   {
-      String responseBody = getResponseBody("jbosstest-jsf");
-      assertFalse(contains(responseBody, "facelets.compiler"));
-   }
-   
-   public void testFaceletsLogging() throws Exception
-   {
-      String responseBody = getResponseBody("jbosstest-jsf-facelets");
-      assertTrue(contains(responseBody, "facelets.compiler"));
-      assertTrue(contains(responseBody, "facelets.factory"));
-      assertTrue(contains(responseBody, "facelets.tag.component"));
-      assertTrue(contains(responseBody, "facelets.viewhandler"));
-      assertTrue(contains(responseBody, "facelets.tag.meta"));
-   }
 
    public void testJSFAppWithBundledMyFaces() throws Exception
    {
@@ -185,9 +127,6 @@
 
    public static Test suite() throws Exception
    {
-      // need to set up the JSF loggers before the WAR is deployed
-      setLoggingLevels();
-      
       TestSuite suite = new TestSuite();
       suite.addTest(new TestSuite(JSFIntegrationUnitTestCase.class));
 
@@ -198,13 +137,11 @@
          {
             super.setUp();
             deploy("jbosstest-jsf.war");   
-            deploy("jbosstest-jsf-facelets.war");
             deploy("bundled-myfaces-hellojsf.war");            
          }
          protected void tearDown() throws Exception
          {
             undeploy("bundled-myfaces-hellojsf.war");
-            undeploy("jbosstest-jsf-facelets.war");
             undeploy("jbosstest-jsf.war");
             super.tearDown();            
          }

Modified: trunk/testsuite/src/resources/web/WEB-INF/jsftest-web.xml
===================================================================
--- trunk/testsuite/src/resources/web/WEB-INF/jsftest-web.xml	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/testsuite/src/resources/web/WEB-INF/jsftest-web.xml	2009-04-06 17:14:23 UTC (rev 86861)
@@ -4,6 +4,12 @@
 	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
 	 version="2.5">
+   
+   <context-param>
+      <param-name>com.sun.faces.displayConfiguration</param-name>
+      <param-value>true</param-value>
+   </context-param>
+
     <!-- The JavaServer Faces Servlet -->
    <servlet>
       <servlet-name>javax.faces.FacesServlet</servlet-name>

Modified: trunk/testsuite/src/resources/web/html/jsftest/index.jsp
===================================================================
--- trunk/testsuite/src/resources/web/html/jsftest/index.jsp	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/testsuite/src/resources/web/html/jsftest/index.jsp	2009-04-06 17:14:23 UTC (rev 86861)
@@ -41,13 +41,5 @@
          <h3><h:outputText value="JButton value = #{myJButton}"/></h3>
      </f:view>
  
-       <font color="red"><h1>Logging Test</h1></font>
-       <h3>
-       <%
-           LoggingTest loggingTest = new LoggingTest();
-           loggingTest.sendLogMessages();
-           out.println(loggingTest.getLoggedMessages());
-        %>
-       </h3>
     </body>
 </html>

Modified: trunk/thirdparty/pom.xml
===================================================================
--- trunk/thirdparty/pom.xml	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/thirdparty/pom.xml	2009-04-06 17:14:23 UTC (rev 86861)
@@ -1877,10 +1877,6 @@
       <artifactId>jsf-api</artifactId>
     </dependency>
     <dependency>
-        <groupId>com.sun.facelets</groupId>
-        <artifactId>jsf-facelets</artifactId>
-    </dependency>
-    <dependency>
       <groupId>sun-jaxws</groupId>
       <artifactId>jaxws-rt</artifactId>
     </dependency>    

Deleted: trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/FaceletsLoggers.java	2009-04-06 17:14:23 UTC (rev 86861)
@@ -1,166 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.jboss.web.jsf.integration.config;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * This class provides access to the loggers used by Facelets version 1.1.15.
- *
- * @author Stan Silvert
- * @author Pete Muir
- */
-public class FaceletsLoggers 
-{
-    
-   // Don't allow an instance of this class
-   private FaceletsLoggers() {}
-    
-   /**
-    * Determine if Facelets is in the classpath.
-    *
-    * @return <code>true</code> if Facelets is available,
-    *         <code>false</code> otherwise.
-    */
-   public static boolean isFaceletsAvailable()
-   {
-      try
-      {
-         classForName("com.sun.facelets.Facelet");
-         return true;
-      } 
-      catch (ClassNotFoundException e)
-      {
-         return false;
-      }
-   }
-   
-   /**
-    * Return an Iterator of all the java.util.logging.Logger objects used
-    * in Facelets.
-    *
-    * @return The Loggers, or an empty Iterator if Facelets is not available.
-    */
-   public static Iterator<Logger> getLoggers() throws Exception
-   {
-      List<Logger> loggers = new ArrayList<Logger>();
-      
-      if (!isFaceletsAvailable()) return loggers.iterator();
-      
-      // Gah have to do this by reflection as the loggers are protected
-         
-      // And some aren't static, so this really is best effort
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.TagLibraryConfig", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.Compiler", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.impl.DefaultFaceletFactory", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.jsf.ComponentHandler", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.util.Resource", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.FaceletViewHandler", "log"));
-
-      // These ones are in a package-scoped class
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.compiler.CompilationManager", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.jsf.ComponentRule", "log"));
-      loggers.add(getPrivateStaticLogger("com.sun.facelets.tag.MetaRulesetImpl", "log"));
-         
-      return loggers.iterator();
-   }
-   
-   private static Logger getPrivateStaticLogger(Class clazz, String fieldName) throws Exception 
-   {
-      Field field = getField(clazz, fieldName);
-      field.setAccessible(true);
-      return (Logger) get(field, new Object());
-   }
-   
-   private static Logger getPrivateStaticLogger(String className, String fieldName) throws Exception
-   {
-      return getPrivateStaticLogger(classForName(className), fieldName);
-   }
-   
-   // Code copied from org.jboss.seam.util.Reflctions
-   private static Object get(Field field, Object target) throws Exception
-   {
-      try
-      {
-         return field.get(target);
-      }
-      catch (IllegalArgumentException iae)
-      {
-         String message = "Could not get field value by reflection: " + toString(field) + 
-            " on: " + target.getClass().getName();
-         throw new IllegalArgumentException(message, iae);
-      }
-   }
-   
-   // Code copied from org.jboss.seam.util.Reflctions
-   private static Field getField(Class clazz, String name)
-   {
-      for ( Class superClass = clazz; superClass!=Object.class; superClass=superClass.getSuperclass() )
-      {
-         try
-         {
-            return superClass.getDeclaredField(name);
-         }
-         catch (NoSuchFieldException nsfe) {}
-      }
-      throw new IllegalArgumentException("no such field: " + clazz.getName() + '.' + name);
-   }
-   
-   // Code copied from org.jboss.seam.util.Reflctions
-   private static Class classForName(String name) throws ClassNotFoundException
-   {
-      try 
-      {
-         return Thread.currentThread().getContextClassLoader().loadClass(name);
-      }
-      catch (Exception e)
-      {
-         return Class.forName(name);
-      }
-   }
-   
-   // Code copied from org.jboss.seam.util.Reflctions
-   private static String toString(Member member)
-   {
-      return unqualify( member.getDeclaringClass().getName() ) + 
-            '.' + 
-            member.getName();
-   }
-   
-   // Code copied from org.jboss.seam.util.Strings
-   private static String unqualify(String name)
-   {
-      return unqualify(name, '.');
-   }
-   
-   // Code copied from org.jboss.seam.util.Strings
-   private static String unqualify(String name, char sep)
-   {
-      return name.substring( name.lastIndexOf(sep)+1, name.length() );
-   }
-   
-}

Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java	2009-04-06 17:14:23 UTC (rev 86861)
@@ -22,12 +22,8 @@
 package org.jboss.web.jsf.integration.config;
 
 import com.sun.faces.config.ConfigureListener;
-import com.sun.faces.util.FacesLogger;
-import java.util.Iterator;
-import java.util.logging.Filter;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
-import org.apache.log4j.Level;
 import org.jboss.logging.Logger;
 
 /**
@@ -42,10 +38,6 @@
    
     private static Logger LOG = Logger.getLogger(JBossJSFConfigureListener.class);
     
-    public static final String BASE_JSF_LOGGER = "javax.enterprise.resource.webcontainer.jsf";
-    
-    public static final String SHOULD_LOG_CONFIG_MESSAGES = "com.sun.faces.displayConfiguration";
-    
     private ServletContext servletContext;
     
     private boolean initialized = false;
@@ -61,20 +53,14 @@
     {
         this.servletContext = event.getServletContext();
         if (warBundlesJSFImpl(this.servletContext)) return;
-        
-        // If the pluginClass is not set, assume Log4J
-        if (System.getProperty("org.jboss.logging.Logger.pluginClass") == null) 
-        {
-            setLog4J();
-            setLog4JForFacelets();
-        }
-
+  
         checkForMyFaces();
         initializeJspRuntime();
         initialized = true;
         super.contextInitialized(event);
     }
     
+    @Override
     public void contextDestroyed(ServletContextEvent event) 
     {
         if (initialized)
@@ -116,112 +102,4 @@
         }
     }
 
-    /**
-     * For a given JSF julLogger find the logging level set to the
-     * corresponding log4jLogger.  Then set the julLogger to the
-     * same level as the log4jLogger.
-     *
-     * At this point we know that Log4J is being used.  So we can
-     * reference a real Log4J logger instead of the JBoss one.
-     */
-    private void setLevel(java.util.logging.Logger julLogger)
-    {
-        org.apache.log4j.Logger log4jLogger = 
-            org.apache.log4j.Logger.getLogger(julLogger.getName());
-
-        julLogger.setLevel(java.util.logging.Level.OFF);
-
-        if (log4jLogger.isEnabledFor(Level.FATAL))
-            julLogger.setLevel(java.util.logging.Level.SEVERE);
-
-        if (log4jLogger.isEnabledFor(Level.ERROR))
-            julLogger.setLevel(java.util.logging.Level.SEVERE);
-
-        if (log4jLogger.isEnabledFor(Level.WARN))
-            julLogger.setLevel(java.util.logging.Level.WARNING);
-
-        if (log4jLogger.isEnabledFor(Level.INFO))
-            julLogger.setLevel(java.util.logging.Level.INFO);
- 
-        if (log4jLogger.isEnabledFor(Level.DEBUG)) 
-            julLogger.setLevel(java.util.logging.Level.FINE);
-
-        if (log4jLogger.isEnabledFor(Level.TRACE))
-            julLogger.setLevel(java.util.logging.Level.FINEST);
-
-        if (log4jLogger.isEnabledFor(Level.ALL))
-            julLogger.setLevel(java.util.logging.Level.ALL);
-    }
-
-    private void setLog4JForFacelets()
-    {
-       Filter conversionFilter = new Log4JConversionFilter(logConfigMessages());
-
-       try
-       {  // if Facelets is not used, getLoggers() returns an empty Iterator
-          for (Iterator<java.util.logging.Logger> loggers = FaceletsLoggers.getLoggers(); loggers.hasNext();)
-          {
-             java.util.logging.Logger julLogger = loggers.next();
-             setLevel(julLogger);
-             julLogger.setFilter(conversionFilter);
-          }
-       }
-       catch (Exception e)
-       {
-          LOG.warn("Unable to convert Facelets logging to Log4J", e);
-       }
-    }
-    
-    /**
-     * If Log4J is being used, set a filter that converts JSF RI java.util.logger
-     * messages to Log4J messages.
-     */
-    private void setLog4J() 
-    {
-        Filter conversionFilter = new Log4JConversionFilter(logConfigMessages());
-
-        java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(BASE_JSF_LOGGER);
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-
-        julLogger = FacesLogger.APPLICATION.getLogger();
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-
-        julLogger = FacesLogger.CONFIG.getLogger();
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-
-        julLogger = FacesLogger.CONTEXT.getLogger();
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-
-        julLogger = FacesLogger.LIFECYCLE.getLogger();
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-        
-        julLogger = FacesLogger.MANAGEDBEAN.getLogger();
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-
-        julLogger = FacesLogger.RENDERKIT.getLogger();
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-
-        julLogger = FacesLogger.TAGLIB.getLogger();
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-        
-        julLogger = FacesLogger.TIMING.getLogger();
-        setLevel(julLogger);
-        julLogger.setFilter(conversionFilter);
-    }
-    
-    // should we log the configuration messages?
-    private boolean logConfigMessages() 
-    {
-        String shouldLogConfigParam = this.servletContext.getInitParameter(SHOULD_LOG_CONFIG_MESSAGES);
-        return (shouldLogConfigParam != null) && (shouldLogConfigParam.equalsIgnoreCase("true"));
-    }
-    
 }

Deleted: trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/Log4JConversionFilter.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/Log4JConversionFilter.java	2009-04-06 17:13:54 UTC (rev 86860)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/Log4JConversionFilter.java	2009-04-06 17:14:23 UTC (rev 86861)
@@ -1,183 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.jboss.web.jsf.integration.config;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Filter;
-import java.util.logging.Formatter;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.SimpleFormatter;
-import org.jboss.logging.Logger;
-
-/**
- * This filter is used to convert java.util.logging messages from the JSF RI
- * to Log4J messages.
- *
- * @author Stan Silvert
- */
-public class Log4JConversionFilter implements Filter 
-{
-    
-    // cache Logger instances.  Logger.getLogger() is known to be slow.
-    // See http://www.qos.ch/logging/thinkAgain.jsp
-    private Map<String, Logger> loggerCache = new HashMap<String, Logger>();
-    
-    private Formatter formatter = new SimpleFormatter();
-    
-    // should we log the INFO level config messages that tell about
-    // servlet context params?
-    private boolean logConfigMessages;
-    
-    public Log4JConversionFilter(boolean logConfigMessages) 
-    {
-        this.logConfigMessages = logConfigMessages;
-    }
-    
-    private boolean isConfigStartupMessage(LogRecord record) 
-    {
-        return record.getMessage().equals("jsf.config.listener.version") ||
-               record.getMessage().equals("jsf.config.listener.version.complete");
-    }
-    
-    /**
-     * If the JSF RI message should be logged, convert the JDK 1.4 
-     * LogRecord to a Log4J message.
-     *
-     * @return <code>false</code> because JDK 1.4 logging should not happen
-     *         for JSF if this filter is active.
-     */
-    public boolean isLoggable(LogRecord record) 
-    {
-        if (!logConfigMessages && isConfigStartupMessage(record)) return false;
-        
-        Logger logger = getLogger(record);
-        
-        if (record.getThrown() != null) 
-        {
-            logWithThrowable(logger, record);
-        } 
-        else 
-        {
-            logWithoutThrowable(logger, record);
-        }
-        
-        return false;
-    }
-    
-    private void logWithThrowable(Logger logger, LogRecord record) 
-    {
-        int loggedLevel = record.getLevel().intValue();
-        Object message = formatter.formatMessage(record);
-        Throwable throwable = record.getThrown();
-        
-        if (loggedLevel == Level.SEVERE.intValue())
-        {
-           logger.error(message, throwable);
-           return;
-        }
-
-        if (loggedLevel == Level.WARNING.intValue())
-        {
-           logger.warn(message, throwable);
-           return;
-        }
-
-        if ((loggedLevel == Level.INFO.intValue()) ||
-            (loggedLevel == Level.CONFIG.intValue()))
-        {
-           logger.info(message, throwable);
-           return;
-        }
-        
-        if (loggedLevel == Level.FINE.intValue())
-        {
-           logger.debug(message, throwable);
-           return;
-        }
-
-        if ((loggedLevel == Level.FINER.intValue()) ||
-            (loggedLevel == Level.FINEST.intValue()))
-        {
-           logger.trace(message, throwable);
-           return;
-        }
-    
-        logger.info(message, throwable);
-    }
-    
-    private void logWithoutThrowable(Logger logger, LogRecord record) 
-    {
-        int loggedLevel = record.getLevel().intValue();
-        Object message = formatter.formatMessage(record);
-        
-        if (loggedLevel == Level.SEVERE.intValue())
-        {
-           logger.error(message);
-           return;
-        }
-
-        if (loggedLevel == Level.WARNING.intValue())
-        {
-           logger.warn(message);
-           return;
-        }
-
-        if ((loggedLevel == Level.INFO.intValue()) ||
-            (loggedLevel == Level.CONFIG.intValue()))
-        {
-           logger.info(message);
-           return;
-        }
-        
-        if (loggedLevel == Level.FINE.intValue())
-        {
-           logger.debug(message);
-           return;
-        }
-
-        if ((loggedLevel == Level.FINER.intValue()) ||
-            (loggedLevel == Level.FINEST.intValue()))
-        {
-           logger.trace(message);
-           return;
-        }
-
-        logger.info(message);
-    }
-    
-    // get the Log4J logger corresponding to the java.util.logger.LogRecord
-    private Logger getLogger(LogRecord record) 
-    {
-        String loggerName = record.getLoggerName();
-        Logger logger = loggerCache.get(loggerName);
-        if (logger == null) 
-        {
-            logger = Logger.getLogger(loggerName);
-            loggerCache.put(loggerName, logger);
-        }
-        
-        return logger;
-    }
-    
-}




More information about the jboss-cvs-commits mailing list