[jboss-cvs] JBossAS SVN: r106096 - in projects/jboss-jsf-int/trunk: jsf-deployer/src/main/resources/Mojarra-1.2/META-INF and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 16 17:04:17 EDT 2010


Author: stan.silvert at jboss.com
Date: 2010-06-16 17:04:16 -0400 (Wed, 16 Jun 2010)
New Revision: 106096

Added:
   projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarra12ConfigureListener.java
   projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarra20ConfigureListener.java
   projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarraConfigureListener.java
Removed:
   projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java
Modified:
   projects/jboss-jsf-int/trunk/jsf-deployer/src/main/resources/Mojarra-1.2/META-INF/web.xml
   projects/jboss-jsf-int/trunk/jsf-deployer/src/main/resources/Mojarra-2.0/META-INF/web.xml
Log:
JBAS-8109 Refactor JBossJSFConfigureListener


Deleted: projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java
===================================================================
--- projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java	2010-06-16 20:51:50 UTC (rev 106095)
+++ projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java	2010-06-16 21:04:16 UTC (rev 106096)
@@ -1,143 +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 com.sun.faces.config.ConfigurationException;
-import com.sun.faces.config.ConfigureListener;
-import javax.faces.validator.BeanValidator;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.validation.Validation;
-import javax.validation.ValidatorFactory;
-import org.jboss.logging.Logger;
-import org.jboss.mc.servlet.vdf.spi.VDFConnector;
-import org.jboss.web.validation.ValidatorFactoryVDFConnector;
-
-
-/**
- * This ServletContextListener sets up a JBoss-specific environment for JSF
- * and then delegates the rest of the setup to the JSF RI.
- *
- * @author Stan Silvert
- * @author Ales Justin
- */
-public class JBossJSFConfigureListener extends ConfigureListener 
-{
-    private static final String WAR_BUNDLES_JSF_IMPL = "org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL";
-   
-    private static Logger LOG = Logger.getLogger(JBossJSFConfigureListener.class);
-    
-    private ServletContext servletContext;
-    
-    private boolean initialized = false;
-    
-    public static boolean warBundlesJSFImpl(ServletContext servletContext)
-    {
-       String bundledJSFImpl = servletContext.getInitParameter(WAR_BUNDLES_JSF_IMPL);
-       return (bundledJSFImpl != null) && bundledJSFImpl.equalsIgnoreCase("true");
-    }
-
-    @Override
-    public void contextInitialized(ServletContextEvent event) 
-    {
-        this.servletContext = event.getServletContext();
-        if (warBundlesJSFImpl(this.servletContext)) return;
-  
-        checkForMyFaces();
-        initializeJspRuntime();
-        initialized = true;
-        addBeanValidatorFactory();
-        
-        try
-        {
-           super.contextInitialized(event);
-        }
-        catch (ConfigurationException e)
-        {
-           // HACK! HACK! HACK! This will be cleaned up with JSFDeployer.
-           if ("no web.xml present".equals(e.getMessage())) return;
-           throw e;
-        }
-    }
-    
-    @Override
-    public void contextDestroyed(ServletContextEvent event) 
-    {
-        if (initialized)
-        {
-           initialized = false;
-           super.contextDestroyed(event);
-        }
-    }
-    
-    // This method accounts for a peculiar problem with Jasper that pops up from time
-    // to time.  In some cases, if the JspRuntimeContext is not loaded then the JspFactory
-    // will not be initialized for JSF.  This method assures that it will always be
-    // be loaded before JSF is initialized.
-    private static void initializeJspRuntime() 
-    {
-
-        try 
-        {
-            Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
-        }  
-        catch (ClassNotFoundException cnfe) 
-        {
-            // do nothing 
-        }
-    }
-
-    private void checkForMyFaces()
-    {
-        try
-        {
-            Thread.currentThread()
-                  .getContextClassLoader()
-                  .loadClass("org.apache.myfaces.webapp.StartupServletContextListener");
-            LOG.warn("MyFaces JSF implementation found!  This version of JBoss AS ships with the java.net implementation of JSF.  There are known issues when mixing JSF implementations.  This warning does not apply to MyFaces component libraries such as Tomahawk.  However, myfaces-impl.jar and myfaces-api.jar should not be used without disabling the built-in JSF implementation.  See the JBoss wiki for more details.");
-        }
-        catch (ClassNotFoundException e)
-        {
-            // ignore - this is a good thing
-        }
-    }
-    
-    protected void addBeanValidatorFactory()
-    {
-       VDFConnector<ValidatorFactory> vfc = new ValidatorFactoryVDFConnector(servletContext);
-
-       ValidatorFactory factory;
-       if (vfc.isValid())
-       {
-          factory = vfc.getUtility();
-       }
-       else
-       {
-          LOG.warn("No such ValidatorFactory in VDF layer, creating new instance.");
-          factory = Validation.buildDefaultValidatorFactory();
-       }
-
-       this.servletContext.setAttribute(BeanValidator.VALIDATOR_FACTORY_KEY, factory);
-    }
-
-
-}

Added: projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarra12ConfigureListener.java
===================================================================
--- projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarra12ConfigureListener.java	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarra12ConfigureListener.java	2010-06-16 21:04:16 UTC (rev 106096)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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;
+
+/**
+ * This ServletContextListener avoids unnecessary initialization done by
+ * the JSF 2.0 ConfigureListener.
+ *
+ * @author Stan Silvert
+ */
+public class JBossMojarra12ConfigureListener extends JBossMojarraConfigureListener
+{
+    public void doVersionSpecificInitialization()
+    {
+       // currently doesn't need to do anything
+    }
+
+}

Added: projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarra20ConfigureListener.java
===================================================================
--- projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarra20ConfigureListener.java	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarra20ConfigureListener.java	2010-06-16 21:04:16 UTC (rev 106096)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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 javax.faces.validator.BeanValidator;
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+import org.jboss.logging.Logger;
+import org.jboss.mc.servlet.vdf.spi.VDFConnector;
+import org.jboss.web.validation.ValidatorFactoryVDFConnector;
+
+
+/**
+ * This ServletContextListener adds the BeanValidationFactory needed to
+ * use the JSF 2.0 BeanValidator.
+ *
+ * @author Stan Silvert
+ * @author Ales Justin
+ */
+public class JBossMojarra20ConfigureListener extends JBossMojarraConfigureListener
+{
+    private static Logger LOG = Logger.getLogger(JBossMojarra20ConfigureListener.class);
+
+    public void doVersionSpecificInitialization()
+    {
+       addBeanValidatorFactory();
+    }
+
+    protected void addBeanValidatorFactory()
+    {
+       VDFConnector<ValidatorFactory> vfc = new ValidatorFactoryVDFConnector(servletContext);
+
+       ValidatorFactory factory;
+       if (vfc.isValid())
+       {
+          factory = vfc.getUtility();
+       }
+       else
+       {
+          LOG.warn("No such ValidatorFactory in VDF layer, creating new instance.");
+          factory = Validation.buildDefaultValidatorFactory();
+       }
+
+       servletContext.setAttribute(BeanValidator.VALIDATOR_FACTORY_KEY, factory);
+    }
+
+}

Copied: projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarraConfigureListener.java (from rev 106084, projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossJSFConfigureListener.java)
===================================================================
--- projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarraConfigureListener.java	                        (rev 0)
+++ projects/jboss-jsf-int/trunk/jboss-faces/src/main/java/org/jboss/web/jsf/integration/config/JBossMojarraConfigureListener.java	2010-06-16 21:04:16 UTC (rev 106096)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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 com.sun.faces.config.ConfigureListener;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+
+
+/**
+ * This ServletContextListener sets up a JBoss-specific environment for JSF
+ * and then delegates the rest of the setup to the JSF RI.
+ *
+ * @author Stan Silvert
+ */
+public abstract class JBossMojarraConfigureListener extends ConfigureListener
+{
+    protected ServletContext servletContext;
+    
+    protected boolean initialized = false;
+    
+    @Override
+    public void contextInitialized(ServletContextEvent event) 
+    {
+        this.servletContext = event.getServletContext();
+  
+        initializeJspRuntime();
+        
+        doVersionSpecificInitialization();
+        
+        super.contextInitialized(event);
+        initialized = true;
+    }
+
+    public abstract void doVersionSpecificInitialization();
+
+    @Override
+    public void contextDestroyed(ServletContextEvent event) 
+    {
+        if (initialized)
+        {
+           super.contextDestroyed(event);
+           initialized = false;
+        }
+    }
+    
+    // This method accounts for a peculiar problem with Jasper that pops up from time
+    // to time.  In some cases, if the JspRuntimeContext is not loaded then the JspFactory
+    // will not be initialized for JSF.  This method assures that it will always be
+    // be loaded before JSF is initialized.
+    private static void initializeJspRuntime() 
+    {
+        try 
+        {
+            Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
+        }  
+        catch (ClassNotFoundException cnfe) 
+        {
+            // do nothing 
+        }
+    }
+
+}

Modified: projects/jboss-jsf-int/trunk/jsf-deployer/src/main/resources/Mojarra-1.2/META-INF/web.xml
===================================================================
--- projects/jboss-jsf-int/trunk/jsf-deployer/src/main/resources/Mojarra-1.2/META-INF/web.xml	2010-06-16 20:51:50 UTC (rev 106095)
+++ projects/jboss-jsf-int/trunk/jsf-deployer/src/main/resources/Mojarra-1.2/META-INF/web.xml	2010-06-16 21:04:16 UTC (rev 106096)
@@ -1,50 +1,38 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
-   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
-   version="2.5">
-   <!-- ======================== Introduction ============================== -->
-   <!-- This document defines default values for *all* web applications      -->
-   <!-- loaded into this instance of Tomcat.  As each application is         -->
-   <!-- deployed, this file is processed, followed by the                    -->
-   <!-- "/WEB-INF/web.xml" deployment descriptor from your own               -->
-   <!-- applications.                                                        -->
-   <!--                                                                      -->
-   <!-- WARNING:  Do not configure application-specific resources here!      -->
-   <!-- They should go in the "/WEB-INF/web.xml" file in your application.   -->
-
-   <!-- =========== Common Context Params ================================== -->
-
-   <!-- Regular expression to determine if two different URLs actually point -->
-   <!-- to the same jar file.  This keeps faces-config files from being      -->
-   <!-- read twice.                                                          -->
-   <context-param>
-     <param-name>com.sun.faces.duplicateJARPattern</param-name>
-     <param-value>^tmp\d+(\S*\.jar)</param-value>
-   </context-param>
-    
-   <!-- JBossInjectionProvider provides resource injection for managed beans. -->
-   <!-- See JSF 1.2 spec section 5.4 for details.                             -->
-   <context-param>
-     <param-name>com.sun.faces.injectionProvider</param-name>
-     <param-value>org.jboss.web.jsf.integration.injection.JBossDelegatingInjectionProvider</param-value>
-   </context-param>
-   
-   <!-- ================== Common filter Configuration ==================== -->
-   
-	
-   <!-- ================== Common Listener Configuration ==================== -->
-   <!-- Configures JSF for a web application if the javax.faces.webapp.FacesServlet is declared -->
-   <!-- in web.xml.                                                                             -->
-   <listener>
-     <listener-class>org.jboss.web.jsf.integration.config.JBossJSFConfigureListener</listener-class>
-   </listener>
-
-   <!-- Listens to all web app lifecycle events so that @PreDestroy can be called on -->
-   <!-- JSF managed beans that go out of scope.  You can comment this out if you     -->
-   <!-- don't use JSF or you don't use annotations on your managed beans.            
-   <listener>
-     <listener-class>com.sun.faces.application.WebappLifecycleListener</listener-class>
-   </listener> -->
-
-</web-app>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+   version="2.5">
+   <!-- ======================== Introduction ============================== -->
+   <!-- This document defines default values for the Mojarra-1.2 JSF config  -->
+   <!--                                                                      -->
+   <!-- WARNING:  Do not configure application-specific resources here!      -->
+   <!-- They should go in the "/WEB-INF/web.xml" file in your application.   -->
+
+   <!-- =========== Common Context Params ================================== -->
+
+   <!-- Regular expression to determine if two different URLs actually point -->
+   <!-- to the same jar file.  This keeps faces-config files from being      -->
+   <!-- read twice.                                                          -->
+   <context-param>
+     <param-name>com.sun.faces.duplicateJARPattern</param-name>
+     <param-value>^tmp\d+(\S*\.jar)</param-value>
+   </context-param>
+    
+   <!-- JBossInjectionProvider provides resource injection for managed beans. -->
+   <!-- See JSF 1.2 spec section 5.4 for details.                             -->
+   <context-param>
+     <param-name>com.sun.faces.injectionProvider</param-name>
+     <param-value>org.jboss.web.jsf.integration.injection.JBossDelegatingInjectionProvider</param-value>
+   </context-param>
+   
+   <!-- ================== Common filter Configuration ==================== -->
+   
+	
+   <!-- ================== Common Listener Configuration ==================== -->
+   <!-- Configures JSF 1.2 -->
+   <listener>
+     <listener-class>org.jboss.web.jsf.integration.config.JBossMojarra12ConfigureListener</listener-class>
+   </listener>
+
+</web-app>

Modified: projects/jboss-jsf-int/trunk/jsf-deployer/src/main/resources/Mojarra-2.0/META-INF/web.xml
===================================================================
--- projects/jboss-jsf-int/trunk/jsf-deployer/src/main/resources/Mojarra-2.0/META-INF/web.xml	2010-06-16 20:51:50 UTC (rev 106095)
+++ projects/jboss-jsf-int/trunk/jsf-deployer/src/main/resources/Mojarra-2.0/META-INF/web.xml	2010-06-16 21:04:16 UTC (rev 106096)
@@ -4,11 +4,7 @@
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <!-- ======================== Introduction ============================== -->
-   <!-- This document defines default values for *all* web applications      -->
-   <!-- loaded into this instance of Tomcat.  As each application is         -->
-   <!-- deployed, this file is processed, followed by the                    -->
-   <!-- "/WEB-INF/web.xml" deployment descriptor from your own               -->
-   <!-- applications.                                                        -->
+   <!-- This document defines default values for the Mojarra-2.0 JSF config  -->
    <!--                                                                      -->
    <!-- WARNING:  Do not configure application-specific resources here!      -->
    <!-- They should go in the "/WEB-INF/web.xml" file in your application.   -->
@@ -34,17 +30,9 @@
    
 	
    <!-- ================== Common Listener Configuration ==================== -->
-   <!-- Configures JSF for a web application if the javax.faces.webapp.FacesServlet is declared -->
-   <!-- in web.xml.                                                                             -->
+   <!-- Configures JSF 2.0 -->
    <listener>
-     <listener-class>org.jboss.web.jsf.integration.config.JBossJSFConfigureListener</listener-class>
+     <listener-class>org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener</listener-class>
    </listener>
 
-   <!-- Listens to all web app lifecycle events so that @PreDestroy can be called on -->
-   <!-- JSF managed beans that go out of scope.  You can comment this out if you     -->
-   <!-- don't use JSF or you don't use annotations on your managed beans.            -->
-   <listener>
-     <listener-class>com.sun.faces.application.WebappLifecycleListener</listener-class>
-   </listener>
-
 </web-app>



More information about the jboss-cvs-commits mailing list