You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2010/10/30 14:31:17 UTC

svn commit: r1029046 - /myfaces/core/trunk/implee6/src/main/java/org/apache/myfaces/ee6/MyFacesContainerInitializer.java

Author: matzew
Date: Sat Oct 30 12:31:17 2010
New Revision: 1029046

URL: http://svn.apache.org/viewvc?rev=1029046&view=rev
Log:
MYFACES-2952 Improve Atmosphere Meteor support of MyFaces

making Servlet 3.0 container hook aware of the flag

Modified:
    myfaces/core/trunk/implee6/src/main/java/org/apache/myfaces/ee6/MyFacesContainerInitializer.java

Modified: myfaces/core/trunk/implee6/src/main/java/org/apache/myfaces/ee6/MyFacesContainerInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/implee6/src/main/java/org/apache/myfaces/ee6/MyFacesContainerInitializer.java?rev=1029046&r1=1029045&r2=1029046&view=diff
==============================================================================
--- myfaces/core/trunk/implee6/src/main/java/org/apache/myfaces/ee6/MyFacesContainerInitializer.java (original)
+++ myfaces/core/trunk/implee6/src/main/java/org/apache/myfaces/ee6/MyFacesContainerInitializer.java Sat Oct 30 12:31:17 2010
@@ -98,6 +98,7 @@ public class MyFacesContainerInitializer
      */
     private static final String FACES_SERVLET_ADDED_ATTRIBUTE = "org.apache.myfaces.DYNAMICALLY_ADDED_FACES_SERVLET";
     
+    private static final String INITIALIZE_ALWAYS_STANDALONE = "org.apache.myfaces.INITIALIZE_ALWAYS_STANDALONE";
     private static final String FACES_CONFIG_RESOURCE = "/WEB-INF/faces-config.xml";
     private static final Logger log = Logger.getLogger(MyFacesContainerInitializer.class.getName());
     private static final String[] FACES_SERVLET_MAPPINGS = { "/faces/*", "*.jsf", "*.faces" };
@@ -107,6 +108,16 @@ public class MyFacesContainerInitializer
 
     public void onStartup(Set<Class<?>> clazzes, ServletContext servletContext) throws ServletException
     {
+        boolean startDireclty = shouldStartupRegardless(servletContext);
+
+        if (startDireclty)
+        {
+            // if the INITIALIZE_ALWAYS_STANDALONE param was set to true,
+            // we do not want to have the FacesServlet beeing added, we simply 
+            // do no extra configuration in here.
+            return;
+        }
+
         if ((clazzes != null && !clazzes.isEmpty()) || isFacesConfigPresent(servletContext))
         {
             // look for the FacesServlet
@@ -154,6 +165,26 @@ public class MyFacesContainerInitializer
     }
 
     /**
+     * Checks if the <code>INITIALIZE_ALWAYS_STANDALONE</code> flag is ture in <code>web.xml</code>.
+     * If the flag is true, this means we should not add the FacesServlet, instead we want to
+     * init MyFaces regardless...
+     */
+    private boolean shouldStartupRegardless(ServletContext servletContext)
+    {
+        try
+        {
+            String standaloneStartup = servletContext.getInitParameter(INITIALIZE_ALWAYS_STANDALONE);
+
+            // "true".equalsIgnoreCase(param) is faster than Boolean.valueOf()
+            return "true".equalsIgnoreCase(standaloneStartup);
+        }
+        catch (Exception e)
+        {
+            return false;
+        }
+    }
+
+    /**
      * Checks if /WEB-INF/faces-config.xml is present.
      * @return
      */