click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r752040 - in /incubator/click/branches/click-2.0.x: documentation/docs/roadmap-changes.html examples/webapp/WEB-INF/web.xml extras/src/org/apache/click/extras/filter/PerformanceFilter.java
Date Tue, 10 Mar 2009 10:34:06 GMT
Author: sabob
Date: Tue Mar 10 10:34:05 2009
New Revision: 752040

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

Modified:
    incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html
    incubator/click/branches/click-2.0.x/examples/webapp/WEB-INF/web.xml
    incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/filter/PerformanceFilter.java

Modified: incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html?rev=752040&r1=752039&r2=752040&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html Tue Mar 10
10:34:05 2009
@@ -87,6 +87,10 @@
           a page by decreasing the buffer size used for including HTML imports.
       </li>
       <li class="change">
+          Improved PerformanceFilter to implement exclude-paths filtering
+ 	 		    [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-498">498</a>].
+ 	 		</li>
+      <li class="change">
           <a class="external" target="_blank" href="http://code.google.com/p/click-calendar/">Click
Calendar</a>
           version 1.0.1 has been released which fixes a memory leak in the calendar popup
           [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-499">499</a>].

Modified: incubator/click/branches/click-2.0.x/examples/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/examples/webapp/WEB-INF/web.xml?rev=752040&r1=752039&r2=752040&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/examples/webapp/WEB-INF/web.xml (original)
+++ incubator/click/branches/click-2.0.x/examples/webapp/WEB-INF/web.xml Tue Mar 10 10:34:05
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/branches/click-2.0.x/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/filter/PerformanceFilter.java?rev=752040&r1=752039&r2=752040&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
(original)
+++ incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
Tue Mar 10 10:34:05 2009
@@ -297,12 +297,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);
 
@@ -468,6 +473,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
@@ -480,8 +513,8 @@
     /**
      * Removes the version indicator from the specified path.
      * <p/>
-     * For example, given the path <tt>'/example/control-1.4.js'</tt>, where
-     * <tt>'-1.4'</tt> is the <tt>version indicator</tt>, this method
will
+     * For example, given the path <tt>'/example/control_1.4.js'</tt>, where
+     * <tt>'_1.4'</tt> is the <tt>version indicator</tt>, this method
will
      * return <tt>'/example/control.js'</tt>.
      *
      * @see #getResourceVersionIndicator(String)



Mime
View raw message