click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r752035 - in /incubator/click/trunk/click: examples/webapp/WEB-INF/web.xml extras/src/org/apache/click/extras/filter/PerformanceFilter.java
Date Tue, 10 Mar 2009 10:29:12 GMT
Author: sabob
Date: Tue Mar 10 10:29:11 2009
New Revision: 752035

URL: http://svn.apache.org/viewvc?rev=752035&view=rev
Log:
forwardported PerformanceFilter excludes. CLK-498

Modified:
    incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml
    incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java

Modified: incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml?rev=752035&r1=752034&r2=752035&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml (original)
+++ incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml Tue Mar 10 10:29:11 2009
@@ -52,6 +52,8 @@
 	and sets the Expires header on selected static resources. 
 	The "cachable-paths" init parameter tells the filter resources can have 
 	their Expires header set so the browser will cache them.
+  The "excludes-path" init parameter tells the filter which requests should
+	be ignored by the filter.
 	-->
 	<filter>
 		<filter-name>PerformanceFilter</filter-name>
@@ -60,6 +62,10 @@
 			<param-name>cachable-paths</param-name>
  			<param-value>/assets/*</param-value>
 		</init-param>
+    <init-param>
+			<param-name>exclude-paths</param-name>
+ 			<param-value>*/excel-export.htm</param-value>
+		</init-param>
 	</filter>
 
  	<filter-mapping>

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java?rev=752035&r1=752034&r2=752035&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
Tue Mar 10 10:29:11 2009
@@ -321,12 +321,17 @@
         final HttpServletRequest request = (HttpServletRequest) servletRequest;
         final HttpServletResponse response = (HttpServletResponse) servletResponse;
 
+        final String path = ClickUtils.getResourcePath(request);
+
+        if (isExcludePath(path)) {
+            chain.doFilter(servletRequest, servletResponse);
+            return;
+        }
+
         // Enable resource versioning in Click
         request.setAttribute(ClickUtils.ENABLE_RESOURCE_VERSION, "true");
 
         // Apply cache expiry Headers
-        final String path = ClickUtils.getResourcePath(request);
-
         if (useForeverCacheHeader(path)) {
             setHeaderExpiresCache(response, FOREVER_CACHE_MAX_AGE);
 
@@ -492,6 +497,34 @@
     }
 
     /**
+     * Return true if a path should be excluded from the performance filter.
+     *
+     * @param path the request path to test
+     * @return true if the response should be excluded from the performance filter
+     */
+    protected boolean isExcludePath(String path) {
+        if (!excludeFiles.isEmpty()) {
+            for (int i = 0; i < excludeFiles.size(); i++) {
+                String file = excludeFiles.get(i).toString();
+                if (path.endsWith(file)) {
+                    return true;
+                }
+            }
+        }
+
+        if (!excludeFiles.isEmpty()) {
+            for (int i = 0; i < excludeDirs.size(); i++) {
+                String dir = excludeDirs.get(i).toString();
+                if (path.startsWith(dir)) {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+    /**
      * Return the <tt>version indicator</tt> for the specified path.
      *
      * @param path the resource path



Mime
View raw message