Author: ivaynberg
Date: Thu Jul 17 10:54:58 2008
New Revision: 677653

URL: http://svn.apache.org/viewvc?rev=677653&view=rev
Log:
WICKET-1753

Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java?rev=677653&r1=677652&r2=677653&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
 Thu Jul 17 10:54:58 2008
@@ -21,7 +21,9 @@
 import java.io.UnsupportedEncodingException;
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Properties;
+import java.util.Set;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -57,6 +59,13 @@
 /**
  * Filter for initiating handling of Wicket requests.
  * 
+ * @see WicketServlet for documentation
+ * 
+ * @author Jonathan Locke
+ * @author Timur Mehrvarz
+ * @author Juergen Donnerstag
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Al Maw
  * @author jcompagner
  */
 public class WicketFilter implements Filter
@@ -74,6 +83,13 @@
        /** Log. */
        private static final Logger log = 
LoggerFactory.getLogger(WicketFilter.class);
 
+
+       /**
+        * Name of parameter used to express a comma separated list of paths 
that should be ignored
+        */
+       public static final String IGNORE_PATHS_PARAM = "ignorePaths";
+
+
        /**
         * The servlet path holder when the WicketSerlvet is used. So that the 
filter path will be
         * computed with the first request. Note: This variable is by purpose 
package protected. See
@@ -133,6 +149,9 @@
         */
        private boolean portletOnlyFilter;
 
+       /** set of paths that should be ignored by the wicket filter */
+       private final Set<String> ignorePaths = new HashSet<String>();
+
        /**
         * Servlet cleanup.
         */
@@ -177,7 +196,21 @@
                        return;
                }
 
-               String relativePath = getRelativePath(httpServletRequest);
+               final String relativePath = getRelativePath(httpServletRequest);
+
+               if (ignorePaths.size() > 0 && relativePath.length() > 0)
+               {
+                       for (String path : ignorePaths)
+                       {
+                               if (relativePath.startsWith(path))
+                               {
+                                       log.debug("Ignoring request {}", 
httpServletRequest.getRequestURL());
+                                       chain.doFilter(request, response);
+                                       return;
+                               }
+                       }
+               }
+
 
                if (isWicketRequest(relativePath))
                {
@@ -489,6 +522,8 @@
         */
        public void init(FilterConfig filterConfig) throws ServletException
        {
+               initIgnorePaths(filterConfig);
+
                this.filterConfig = filterConfig;
                String filterMapping = 
filterConfig.getInitParameter(WicketFilter.FILTER_MAPPING_PARAM);
 
@@ -591,6 +626,28 @@
                }
        }
 
+       /**
+        * initializes the ignore paths parameter
+        * 
+        * @param filterConfig
+        */
+       private void initIgnorePaths(FilterConfig filterConfig)
+       {
+               String paths = 
filterConfig.getInitParameter(IGNORE_PATHS_PARAM);
+               if (!Strings.isEmpty(paths))
+               {
+                       String[] parts = paths.split(",");
+                       for (String path : parts)
+                       {
+                               if (path.startsWith("/"))
+                               {
+                                       path = path.substring(1);
+                               }
+                               ignorePaths.add(path);
+                       }
+               }
+       }
+
        protected boolean isPortletContextAvailable(FilterConfig config) throws 
ServletException
        {
                boolean detectPortletContext = false;

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java?rev=677653&r1=677652&r2=677653&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketServlet.java
 Thu Jul 17 10:54:58 2008
@@ -56,8 +56,7 @@
  * Note that the applicationClassName parameter you specify must be the fully 
qualified name of a
  * class that extends WebApplication. If your class cannot be found, does not 
extend WebApplication
  * or cannot be instantiated, a runtime exception of type 
WicketRuntimeException will be thrown.
- * </p>
- * As an alternative, you can configure an application factory instead. This 
looks like:
+ * </p> As an alternative, you can configure an application factory instead. 
This looks like:
  * 
  * <pre>
  * &lt;init-param&gt;
@@ -69,6 +68,17 @@
  * and it has to satisfy interface [EMAIL PROTECTED] 
org.apache.wicket.protocol.http.IWebApplicationFactory}.
  * 
  * <p>
+ * The servlet can also be configured to skip certain paths, this is 
especially useful when the
+ * servlet is mapped to <code>/*</code> mapping:
+ * 
+ * <pre>
+ * &lt;init-param&gt;
+ *   &lt;param-name&gt;ignorePaths&lt;/param-name&gt;
+ *   &lt;param-value&gt;/images/products/,/documents/pdf/&lt;/param-value&gt;
+ * &lt;/init-param&gt;
+ * </pre>
+ * 
+ * <p>
  * When GET/POST requests are made via HTTP, a WebRequestCycle object is 
created from the request,
  * response and session objects (after wrapping them in the appropriate wicket 
wrappers). The
  * RequestCycle's render() method is then called to produce a response to the 
HTTP request.


Reply via email to