myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r697279 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter: PortletUtils.java TomahawkFacesContextFactory.java
Date Fri, 19 Sep 2008 23:30:49 GMT
Author: lu4242
Date: Fri Sep 19 16:30:48 2008
New Revision: 697279

URL: http://svn.apache.org/viewvc?rev=697279&view=rev
Log:
TOMAHAWK-1170 Resource mapping missing / throwExtensionsFilterMissing reported incorrectly
under load

Added:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java
  (with props)
Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextFactory.java

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java?rev=697279&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java
(added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java
Fri Sep 19 16:30:48 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.webapp.filter;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+
+import org.apache.commons.fileupload.portlet.PortletFileUpload;
+
+/**
+ * This class is used to hold some utilities used by tomahawk in portlet
+ * environments. The idea is that all calls to portlet api methods
+ * should be done here, to avoid ClassNotFoundException error in
+ * servlet environments.
+ * 
+ * The public methods should not use classes on portlet api, so the
+ * other classes calling this class does not have dependencies to this api.
+ * 
+ * @since 1.1.8
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class PortletUtils
+{
+
+    public static boolean isDisabledTomahawkFacesContextWrapper(Object contextOrConfig)
+    {
+        PortletContext portletContext = null;
+        if (contextOrConfig instanceof PortletConfig)
+        {
+            portletContext = ((PortletConfig)contextOrConfig).getPortletContext();
+        }
+        else
+        {
+            portletContext = (PortletContext)contextOrConfig;
+        }
+        
+        return getBooleanValue(portletContext.getInitParameter(
+                TomahawkFacesContextFactory.DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER),
+                TomahawkFacesContextFactory.DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER_DEFAULT);
+    }
+    
+    private static boolean getBooleanValue(String initParameter, boolean defaultVal)
+    {
+        if(initParameter == null || initParameter.trim().length()==0)
+            return defaultVal;
+
+        return (initParameter.equalsIgnoreCase("on") || initParameter.equals("1") || initParameter.equalsIgnoreCase("true"));
+    }
+    
+    public static boolean isMultipartContent(Object request)
+    {
+        if (request instanceof ActionRequest)
+        {
+            return PortletFileUpload.isMultipartContent((ActionRequest)request);
+        }
+        else
+        {
+            return false;
+        }
+    }
+    
+    public static String getContextInitParameter(Object context, String paramName)
+    {
+        PortletContext portletContext = (PortletContext) context;
+        return portletContext.getInitParameter(paramName);
+    }
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextFactory.java?rev=697279&r1=697278&r2=697279&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextFactory.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextFactory.java
Fri Sep 19 16:30:48 2008
@@ -50,6 +50,8 @@
     public static final String DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER = 
         "org.apache.myfaces.DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER";
     
+    public static final boolean DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER_DEFAULT = true;
+    
     private FacesContextFactory delegate;
 
     public TomahawkFacesContextFactory(FacesContextFactory delegate) {
@@ -67,7 +69,8 @@
             //use TomahawkFacesContextWrapper 
             if (servletRequest.getAttribute(ExtensionsFilter.DOFILTER_CALLED) == null &&
                     !getBooleanValue(servletContext.getInitParameter(
-                            DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER), false))
+                            DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER),
+                            DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER_DEFAULT))
             {
                 //This is servlet world
                 //For handle buffered response we need to wrap response object here,
@@ -85,6 +88,10 @@
                     return new TomahawkFacesContextWrapper(delegate.getFacesContext(context,
request, extensionsResponseWrapper, lifecycle),
                             extensionsResponseWrapper);
                 }
+                else
+                {
+                    return new TomahawkFacesContextWrapper(delegate.getFacesContext(context,
request, response, lifecycle));
+                }
             }
             else
             {
@@ -93,7 +100,14 @@
                 return delegate.getFacesContext(context, request, response, lifecycle);
             }
         }
-        return new TomahawkFacesContextWrapper(delegate.getFacesContext(context, request,
response, lifecycle));
+        else
+        {
+            if (!PortletUtils.isDisabledTomahawkFacesContextWrapper(context))
+            {            
+                return new TomahawkFacesContextWrapper(delegate.getFacesContext(context,
request, response, lifecycle));
+            }
+        }    
+        return delegate.getFacesContext(context, request, response, lifecycle);
     }
     
     private static boolean getBooleanValue(String initParameter, boolean defaultVal)



Mime
View raw message