[Jboss-cvs] JBossAS SVN: r56035 - in trunk/tomcat: . src/main/org/jboss/web/jsf/integration src/main/org/jboss/web/jsf/integration/config src/main/org/jboss/web/jsf/integration/serialization src/resources

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 17 15:59:15 EDT 2006


Author: stan.silvert at jboss.com
Date: 2006-08-17 15:59:11 -0400 (Thu, 17 Aug 2006)
New Revision: 56035

Added:
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java
Modified:
   trunk/tomcat/build.xml
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java
   trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/Log4JConversionFilter.java
   trunk/tomcat/src/resources/web.xml
Log:
Added support for JBoss Serialization in JSF (JBAS-3529) and did some cleanup


Modified: trunk/tomcat/build.xml
===================================================================
--- trunk/tomcat/build.xml	2006-08-17 17:59:43 UTC (rev 56034)
+++ trunk/tomcat/build.xml	2006-08-17 19:59:11 UTC (rev 56035)
@@ -60,6 +60,7 @@
       <path refid="jgroups.jgroups.classpath"/>
       <path refid="apache.modeler.classpath"/>
       <path refid="jboss.jbossxb.classpath"/>
+      <path refid="jboss.serialization.classpath"/>
     </path>
 
     <!-- ======= -->
@@ -119,8 +120,8 @@
     <path id="javac.tomcat.classpath">
       <pathelement path="${classpath}"/>
       <pathelement path="${local.classpath}"/>
+      <path refid="apache.tomcat.classpath"/>
       <path refid="thirdparty.classpath"/>
-      <path refid="apache.tomcat.classpath"/>
     </path>
 
     <!-- The classpath required to build classes. -->

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	2006-08-17 17:59:43 UTC (rev 56034)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java	2006-08-17 19:59:11 UTC (rev 56035)
@@ -39,20 +39,23 @@
  *
  * @author Stan Silvert
  */
-public class JBossJSFConfigureListener extends ConfigureListener {
+public class JBossJSFConfigureListener extends ConfigureListener 
+{
     
     private static Logger LOG = Logger.getLogger(JBossJSFConfigureListener.class);
     
-    public static final String SHOULD_LOG_CONFIG_MESSAGES = "org.jboss.faces.logConfigParams";
+    public static final String SHOULD_LOG_CONFIG_MESSAGES = "com.sun.faces.displayConfiguration";
     
     private ServletContext servletContext;
     
     @Override
-    public void contextInitialized(ServletContextEvent event) {
+    public void contextInitialized(ServletContextEvent event) 
+    {
         this.servletContext = event.getServletContext();
         
         // If the pluginClass is not set, assume Log4J
-        if (System.getProperty("org.jboss.logging.Logger.pluginClass") == null) {
+        if (System.getProperty("org.jboss.logging.Logger.pluginClass") == null) 
+        {
             setLog4J();
         }
 
@@ -60,10 +63,13 @@
         //        if we don't preload JspRuntimeContext then the JSF RI will
         //        get a NullPointerException when it tries to register a
         //        ELResolver with JSP.
-        try {
+        try 
+        {
             Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
             JspFactory.getDefaultFactory();  //make sure we can get the factory
-        } catch (Exception e) {
+        } 
+        catch (Exception e) 
+        {
             LOG.error("Unable to initialize Jasper JspRuntimeContext", e);
         }
 
@@ -74,7 +80,8 @@
      * If Log4J is being used, set a filter that converts JSF RI java.util.logger
      * messages to Log4J messages.
      */
-    private void setLog4J() {
+    private void setLog4J() 
+    {
         Filter conversionFilter = new Log4JConversionFilter(logConfigMessages());
         
         java.util.logging.Logger.getLogger(Util.FACES_LOGGER)
@@ -94,7 +101,8 @@
     }
     
     // should we log the configuration messages?
-    private boolean logConfigMessages() {
+    private boolean logConfigMessages() 
+    {
         String shouldLogConfigParam = this.servletContext.getInitParameter(SHOULD_LOG_CONFIG_MESSAGES);
         return (shouldLogConfigParam != null) && (shouldLogConfigParam.equalsIgnoreCase("true"));
     }

Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/Log4JConversionFilter.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/Log4JConversionFilter.java	2006-08-17 17:59:43 UTC (rev 56034)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/config/Log4JConversionFilter.java	2006-08-17 19:59:11 UTC (rev 56035)
@@ -40,7 +40,8 @@
  *
  * @author Stan Silvert
  */
-public class Log4JConversionFilter implements Filter {
+public class Log4JConversionFilter implements Filter 
+{
     
     // cache Logger instances.  Logger.getLogger() is known to be slow.
     // See http://www.qos.ch/logging/thinkAgain.jsp
@@ -52,15 +53,15 @@
     // servlet context params?
     private boolean logConfigMessages;
     
-    private static final String FACES_CONFIG_LOGGER = Util.FACES_LOGGER + Util.CONFIG_LOGGER;
-    
-    public Log4JConversionFilter(boolean logConfigMessages) {
+    public Log4JConversionFilter(boolean logConfigMessages) 
+    {
         this.logConfigMessages = logConfigMessages;
     }
     
-    private boolean isConfigInfoMessage(LogRecord record) {
-        return record.getLevel().equals(Level.INFO) &&
-               record.getLoggerName().equals(FACES_CONFIG_LOGGER);
+    private boolean isConfigStartupMessage(LogRecord record) 
+    {
+        return record.getMessage().equals("jsf.config.listener.version") ||
+               record.getMessage().equals("jsf.config.listener.version.complete");
     }
     
     /**
@@ -70,36 +71,44 @@
      * @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 && isConfigInfoMessage(record)) return false;
+    public boolean isLoggable(LogRecord record) 
+    {
+        if (!logConfigMessages && isConfigStartupMessage(record)) return false;
         
         Logger logger = getLogger(record);
         
-        if (record.getThrown() != null) {
+        if (record.getThrown() != null) 
+        {
             logWithThrowable(logger, record);
-        } else {
+        } 
+        else 
+        {
             logWithoutThrowable(logger, record);
         }
         
         return false;
     }
     
-    private void logWithThrowable(Logger logger, LogRecord record) {
+    private void logWithThrowable(Logger logger, LogRecord record) 
+    {
         int loggedLevel = record.getLevel().intValue();
         Object message = formatter.formatMessage(record);
         Throwable throwable = record.getThrown();
         
-        if (loggedLevel == Level.INFO.intValue()) {
+        if (loggedLevel == Level.INFO.intValue()) 
+        {
             logger.info(message, throwable);
             return;
         }
         
-        if (loggedLevel == Level.WARNING.intValue()) {
+        if (loggedLevel == Level.WARNING.intValue()) 
+        {
             logger.warn(message, throwable);
             return;
         }
         
-        if (loggedLevel == Level.SEVERE.intValue()) {
+        if (loggedLevel == Level.SEVERE.intValue()) 
+        {
             logger.fatal(message, throwable);
             return;
         }
@@ -107,21 +116,25 @@
         logger.info(message, throwable);
     }
     
-    private void logWithoutThrowable(Logger logger, LogRecord record) {
+    private void logWithoutThrowable(Logger logger, LogRecord record) 
+    {
         int loggedLevel = record.getLevel().intValue();
         Object message = formatter.formatMessage(record);
         
-        if (loggedLevel == Level.INFO.intValue()) {
+        if (loggedLevel == Level.INFO.intValue()) 
+        {
             logger.info(message);
             return;
         }
         
-        if (loggedLevel == Level.WARNING.intValue()) {
+        if (loggedLevel == Level.WARNING.intValue()) 
+        {
             logger.warn(message);
             return;
         }
         
-        if (loggedLevel == Level.SEVERE.intValue()) {
+        if (loggedLevel == Level.SEVERE.intValue()) 
+        {
             logger.fatal(message);
             return;
         }
@@ -130,10 +143,12 @@
     }
     
     // get the Log4J logger corresponding to the java.util.logger.LogRecord
-    private Logger getLogger(LogRecord record) {
+    private Logger getLogger(LogRecord record) 
+    {
         String loggerName = record.getLoggerName();
         Logger logger = loggerCache.get(loggerName);
-        if (logger == null) {
+        if (logger == null) 
+        {
             logger = Logger.getLogger(loggerName);
             loggerCache.put(loggerName, logger);
         }

Added: trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java	2006-08-17 17:59:43 UTC (rev 56034)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossFacesObjectInputStream.java	2006-08-17 19:59:11 UTC (rev 56035)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * 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.
+ */
+
+package org.jboss.web.jsf.integration.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectStreamClass;
+import org.jboss.serial.io.JBossObjectInputStream;
+
+/**
+ * Provides override of resolveClass() as required by the JSF spi.  See javadoc
+ * of com.sun.faces.spi.SerializationProvider.createObjectInputStream for details.
+ *
+ * @author Stan Silvert
+ */
+public class JBossFacesObjectInputStream extends JBossObjectInputStream 
+{
+    /**
+     * Create new JBossFacesObjectInputStream.
+     */
+    public JBossFacesObjectInputStream(InputStream source) throws IOException
+    {
+        super(source);
+    }
+    
+    /**
+     * Make sure this resolves to a class from the proper class loader.
+     */
+    protected Class resolveClass(ObjectStreamClass streamClass) throws ClassNotFoundException, IOException 
+    {
+        return Class.forName(streamClass.getName(), true, Thread.currentThread().getContextClassLoader());
+    }
+
+}

Added: trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java	2006-08-17 17:59:43 UTC (rev 56034)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/serialization/JBossSerializationProvider.java	2006-08-17 19:59:11 UTC (rev 56035)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * 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.
+ */
+
+package org.jboss.web.jsf.integration.serialization;
+
+import com.sun.faces.spi.SerializationProvider;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import org.apache.log4j.Logger;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+/**
+ * Provides interface between JSF RI and JBoss Serialization for better
+ * performance of client-side state saving.
+ *
+ * @author Stan Silvert
+ */
+public class JBossSerializationProvider implements SerializationProvider 
+{
+    private static final Logger LOG = Logger.getLogger(JBossSerializationProvider.class);
+
+    /**
+     * No-arg constructor required.
+     */
+    public JBossSerializationProvider() 
+    {
+        LOG.info("Using JBoss Serialization for JavaServer Faces.");
+    }
+    
+    /**
+     * Create a fast ObjectInputStream using JBoss Serialization.
+     */
+    public ObjectInputStream createObjectInputStream(InputStream source) throws IOException {
+        return new JBossFacesObjectInputStream(source);
+    }
+
+    /**
+     * Create a fast ObjectOutputStream using JBoss Serialization.
+     */
+    public ObjectOutputStream createObjectOutputStream(OutputStream destination) throws IOException 
+    {
+        return new JBossObjectOutputStream(destination);
+    }
+    
+}

Modified: trunk/tomcat/src/resources/web.xml
===================================================================
--- trunk/tomcat/src/resources/web.xml	2006-08-17 17:59:43 UTC (rev 56034)
+++ trunk/tomcat/src/resources/web.xml	2006-08-17 19:59:11 UTC (rev 56035)
@@ -31,12 +31,7 @@
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
    </context-param>
-
-   <context-param>
-      <param-name>org.jboss.faces.logConfigParams</param-name>
-      <param-value>false</param-value>
-   </context-param>
-
+   
    <!-- ================== Common filter Configuration ==================== -->
    <filter>
       <filter-name>CommonHeadersFilter</filter-name>




More information about the jboss-cvs-commits mailing list