Author: hlship
Date: Sat Jan 19 09:54:10 2008
New Revision: 613433

URL: http://svn.apache.org/viewvc?rev=613433&view=rev
Log:
TAPESTRY-1595: Add support for ignoring paths that belong to other servlets in 
the web application

Added:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/IgnoredPathsFilter.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/IgnoredPathsFilterTest.java
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Asset.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Link.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/Autocomplete.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/AssetBindingFactory.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizer.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizerImpl.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestPathOptimizerImplTest.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Asset.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Asset.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Asset.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Asset.java
 Sat Jan 19 09:54:10 2008
@@ -29,7 +29,7 @@
      * Returns a URL that can be passed, unchanged, to the client in order for 
it to access the resource. The same value
      * is returned from <code>toString()</code>.
      * <p/>
-     * Note that the returned value may be [EMAIL PROTECTED] 
org.apache.tapestry.TapestryConstants#FORCE_FULL_URIS_SYMBOL
+     * Note that the returned value may be [EMAIL PROTECTED] 
org.apache.tapestry.TapestryConstants#FORCE_ABSOLUTE_URIS_SYMBOL
      * request dependent}. You may cache instances of Asset, but do not cache 
the client URL path as it may change.
      */
     String toClientURL();

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Link.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Link.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Link.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/Link.java
 Sat Jan 19 09:54:10 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -20,35 +20,35 @@
 import java.util.List;
 
 /**
- * A link is the Tapestry representation of a URL or URI that triggers dynamic 
behavior. This link
- * is in three parts: a path portion, an optional anchor, and a set of query 
parameters. A request
- * for a link will ultimately be recognized by a [EMAIL PROTECTED] Dispatcher}.
+ * A link is the Tapestry representation of a URL or URI that triggers dynamic 
behavior. This link is in three parts: a
+ * path portion, an optional anchor, and a set of query parameters. A request 
for a link will ultimately be recognized
+ * by a [EMAIL PROTECTED] Dispatcher}.
  * <p/>
- * Query parameter values are kept separate from the path portion to support 
encoding those values
- * into hidden form fields (where appropriate).
+ * Query parameter values are kept separate from the path portion to support 
encoding those values into hidden form
+ * fields (where appropriate).
  */
 public interface Link
 {
     /**
-     * Returns the names of any additional query parameters for the URI. Query 
parameters store less
-     * regular or less often used values that can not be expressed in the 
path. They also are used
-     * to store, or link to, persistent state.
+     * Returns the names of any additional query parameters for the URI. Query 
parameters store less regular or less
+     * often used values that can not be expressed in the path. They also are 
used to store, or link to, persistent
+     * state.
      *
      * @return list of query parameter names, is alphabetical order
      */
     List<String> getParameterNames();
 
     /**
-     * Returns the value of a specifically named query parameter, or 
<tt>null</tt> if no such
-     * query parameter is stored in the link.
+     * Returns the value of a specifically named query parameter, or 
<tt>null</tt> if no such query parameter is stored
+     * in the link.
      *
      * @return the value of the named parameter
      */
     String getParameterValue(String name);
 
     /**
-     * Adds a parameter value. The value will be added, as is, to the URL. In 
many cases, the value
-     * should be URL encoded via [EMAIL PROTECTED] URLCodec}.
+     * Adds a parameter value. The value will be added, as is, to the URL. In 
many cases, the value should be URL
+     * encoded via [EMAIL PROTECTED] URLCodec}.
      *
      * @param parameterName the name of the parameter to store
      * @param value         the value to store
@@ -57,9 +57,9 @@
     void addParameter(String parameterName, String value);
 
     /**
-     * Returns the URI portion of the link. When the link is created for a 
form, this will not
-     * include query parameters. This is the same value returned from 
toString().  In some circumstances,
-     * this may be a relative URI (relative to the current Request's URI).
+     * Returns the URI portion of the link. When the link is created for a 
form, this will not include query parameters.
+     * This is the same value returned from toString().  In some 
circumstances, this may be a relative URI (relative to
+     * the current Request's URI).
      *
      * @return the URI, ready to be added as an element attribute
      */
@@ -71,8 +71,7 @@
     String toRedirectURI();
 
     /**
-     * Returns the link anchor. If this link does not have an anchor, this 
method returns
-     * <tt>null</tt>.
+     * Returns the link anchor. If this link does not have an anchor, this 
method returns <tt>null</tt>.
      *
      * @return the link anchor
      */
@@ -86,10 +85,10 @@
     void setAnchor(String anchor);
 
     /**
-     * Converts the link to a full URI, a complete path, starting with a 
leading slash. This is necessary
-     * in many cases for client-side JavaScript that must send a request to 
application via XMLHttpRequest.
+     * Converts the link to an absolute URI, a complete path, starting with a 
leading slash. This is necessary in many
+     * cases for client-side JavaScript that must send a request to 
application via XMLHttpRequest.
      *
      * @return the complete URI (not abbreviated relative to the current 
request path)
      */
-    String toFullURI();
+    String toAbsoluteURI();
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryConstants.java
 Sat Jan 19 09:54:10 2008
@@ -76,9 +76,9 @@
 
 
     /**
-     * Symbol which may be set to "true" to force the use of full URIs (not 
relative URIs) exclusively.
+     * Symbol which may be set to "true" to force the use of absolute URIs 
(not relative URIs) exclusively.
      */
-    public static final String FORCE_FULL_URIS_SYMBOL = 
"tapestry.force-full-uris";
+    public static final String FORCE_ABSOLUTE_URIS_SYMBOL = 
"tapestry.force-absolute-uris";
 
 
     /**

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/Autocomplete.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/Autocomplete.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/Autocomplete.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/Autocomplete.java
 Sat Jan 19 09:54:10 2008
@@ -170,7 +170,7 @@
             }
         }
 
-        _pageRenderSupport.addScript("new Ajax.Autocompleter('%s', '%s', '%s', 
%s);", id, menuId, link.toFullURI(),
+        _pageRenderSupport.addScript("new Ajax.Autocompleter('%s', '%s', '%s', 
%s);", id, menuId, link.toAbsoluteURI(),
                                      config);
     }
 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/AssetBindingFactory.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/AssetBindingFactory.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/AssetBindingFactory.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/AssetBindingFactory.java
 Sat Jan 19 09:54:10 2008
@@ -33,7 +33,7 @@
 {
     private final AssetSource _source;
 
-    private final boolean _forceFullURIs;
+    private final boolean _forceAbsoluteURIs;
 
     public class AssetBinding extends AbstractBinding
     {
@@ -66,7 +66,7 @@
         @Override
         public boolean isInvariant()
         {
-            return _forceFullURIs;
+            return _forceAbsoluteURIs;
         }
 
         @Override
@@ -77,10 +77,12 @@
     }
 
     public AssetBindingFactory(AssetSource source,
-                               
@Symbol(TapestryConstants.FORCE_FULL_URIS_SYMBOL)boolean forceFullURIs)
+
+                               
@Symbol(TapestryConstants.FORCE_ABSOLUTE_URIS_SYMBOL)
+                               boolean forceAbsoluteURIs)
     {
         _source = source;
-        _forceFullURIs = forceFullURIs;
+        _forceAbsoluteURIs = forceAbsoluteURIs;
     }
 
     public Binding newBinding(String description, ComponentResources 
container, ComponentResources component,

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/IgnoredPathsFilter.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/IgnoredPathsFilter.java?rev=613433&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/IgnoredPathsFilter.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/IgnoredPathsFilter.java
 Sat Jan 19 09:54:10 2008
@@ -0,0 +1,55 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed 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.tapestry.internal.services;
+
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.RequestFilter;
+import org.apache.tapestry.services.RequestHandler;
+import org.apache.tapestry.services.Response;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.regex.Pattern;
+
+public class IgnoredPathsFilter implements RequestFilter
+{
+    private final Pattern[] _ignoredPatterns;
+
+    public IgnoredPathsFilter(Collection<String> configuration)
+    {
+        _ignoredPatterns = new Pattern[configuration.size()];
+
+        int i = 0;
+
+        for (String regexp : configuration)
+        {
+            Pattern p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE);
+
+            _ignoredPatterns[i++] = p;
+        }
+    }
+
+    public boolean service(Request request, Response response, RequestHandler 
handler) throws IOException
+    {
+        String path = request.getPath();
+
+        for (Pattern p : _ignoredPatterns)
+        {
+            if (p.matcher(path).matches()) return false;
+        }
+
+        return handler.service(request, response);
+    }
+}

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java
 Sat Jan 19 09:54:10 2008
@@ -58,7 +58,8 @@
      * @param optimizer   optimizes complete URLs to appropriate relative URLs
      * @param contextPath path for the context [EMAIL PROTECTED] 
org.apache.tapestry.services.Request#getContextPath()}
      * @param invocation  abstraction around the type of link (needed by 
[EMAIL PROTECTED] org.apache.tapestry.test.PageTester})
-     * @param forForm     if true, then a Form has requested the Link, in 
which case, the link should not generated query parameters directly (they will
+     * @param forForm     if true, then a Form has requested the Link, in 
which case, the link should not generated
+     *                    query parameters directly (they will
      */
     public LinkImpl(Response response, RequestPathOptimizer optimizer, String 
contextPath,
                     ComponentInvocation invocation, boolean forForm)
@@ -90,7 +91,7 @@
         return _response.encodeURL(buildURI(false));
     }
 
-    public String toFullURI()
+    public String toAbsoluteURI()
     {
         return _response.encodeURL(buildURI(true));
     }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizer.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizer.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizer.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizer.java
 Sat Jan 19 09:54:10 2008
@@ -15,20 +15,20 @@
 package org.apache.tapestry.internal.services;
 
 /**
- * Used to optimize a path for inclusion in the rendered output of the page. 
When using lots of libraries,
- * nested folders, and page acivation contexts, you can often create a shorter 
URL as a relative path
- * from the current request URL.  Of course, you need to make sure that's 
turned off inside an Ajax request
- * since the base URL of the client it totally unknown in that situation.
+ * Used to optimize a path for inclusion in the rendered output of the page. 
When using lots of libraries, nested
+ * folders, and page acivation contexts, you can often create a shorter URL as 
a relative path from the current request
+ * URL.  Of course, you need to make sure that's turned off inside an Ajax 
request since the base URL of the client it
+ * totally unknown in that situation.
  *
- * @see org.apache.tapestry.TapestryConstants#FORCE_FULL_URIS_SYMBOL
+ * @see org.apache.tapestry.TapestryConstants#FORCE_ABSOLUTE_URIS_SYMBOL
  */
 public interface RequestPathOptimizer
 {
     /**
-     * Optimizes the provided path, returning a new path that is shorter but 
(combined with the current requests'
-     * base URL) will result in the same request URI.  In many cases, this 
will return the provided path unchanged.
-     * During [EMAIL PROTECTED] org.apache.tapestry.services.Request#isXHR() 
XHR} requests, this will always
-     * return the provided path (no optimization takes place, since the base 
URI of the client is unknown).
+     * Optimizes the provided path, returning a new path that is shorter but 
(combined with the current requests' base
+     * URL) will result in the same request URI.  In many cases, this will 
return the provided path unchanged. During
+     * [EMAIL PROTECTED] org.apache.tapestry.services.Request#isXHR() XHR} 
requests, this will always return the provided path
+     * (no optimization takes place, since the base URI of the client is 
unknown).
      *
      * @param path to be optimized
      * @return the same path, or a new path that is equivalent, relative to 
the current request's URL

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizerImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizerImpl.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizerImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestPathOptimizerImpl.java
 Sat Jan 19 09:54:10 2008
@@ -24,7 +24,7 @@
 {
     private final Request _request;
 
-    private final boolean _forceFull;
+    private final boolean _forceAbsolute;
 
     /**
      * Used to split a URI up into individual folder/file names. Any number of 
consecutive slashes is treated as a
@@ -34,17 +34,17 @@
 
     public RequestPathOptimizerImpl(Request request,
 
-                                    
@Symbol(TapestryConstants.FORCE_FULL_URIS_SYMBOL)
-                                    boolean forceFull)
+                                    
@Symbol(TapestryConstants.FORCE_ABSOLUTE_URIS_SYMBOL)
+                                    boolean forceAbsolute)
     {
         _request = request;
 
-        _forceFull = forceFull;
+        _forceAbsolute = forceAbsolute;
     }
 
-    public String optimizePath(String path)
+    public String optimizePath(String absolutePath)
     {
-        if (_forceFull || _request.isXHR()) return path;
+        if (_forceAbsolute || _request.isXHR()) return absolutePath;
 
         String requestPath = _request.getPath();
 
@@ -62,7 +62,7 @@
 
         if (requestPath.equals("/") || requestPath.equals("")) requestTerms = 
add(requestTerms, "");
 
-        String[] pathTerms = SLASH_PATTERN.split(path);
+        String[] pathTerms = SLASH_PATTERN.split(absolutePath);
 
         builder.setLength(0);
 
@@ -112,12 +112,12 @@
             if (slashx > firstColon) builder.insert(0, "./");
         }
 
-        if (builder.length() < path.length()) return builder.toString();
+        if (builder.length() < absolutePath.length()) return 
builder.toString();
 
-        // The complete path is actually shorter than the relative path, so 
just return the complete
+        // The absolute path is actually shorter than the relative path, so 
just return the absolute
         // path.
 
-        return path;
+        return absolutePath;
     }
 
     private String[] add(String[] array, String s)

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java
 Sat Jan 19 09:54:10 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -29,8 +29,8 @@
 import org.apache.tapestry.test.PageTester;
 
 /**
- * Used in conjuction with [EMAIL PROTECTED] PageTester} to mock up and/or 
stub out portions of Tapestry that
- * need to be handled differently when testing.
+ * Used in conjuction with [EMAIL PROTECTED] PageTester} to mock up and/or 
stub out portions of Tapestry that need to be handled
+ * differently when testing.
  */
 public class PageTesterModule
 {
@@ -74,6 +74,6 @@
 
     public static void 
contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
     {
-        configuration.add(TapestryConstants.FORCE_FULL_URIS_SYMBOL, "true");
+        configuration.add(TapestryConstants.FORCE_ABSOLUTE_URIS_SYMBOL, 
"true");
     }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
 Sat Jan 19 09:54:10 2008
@@ -111,6 +111,7 @@
         binder.bind(ResponseRenderer.class, ResponseRendererImpl.class);
         binder.bind(RequestPathOptimizer.class, 
RequestPathOptimizerImpl.class);
         binder.bind(NullFieldStrategySource.class, 
NullFieldStrategySourceImpl.class);
+        binder.bind(RequestFilter.class, 
IgnoredPathsFilter.class).withId("IgnoredPathsFilter");
     }
 
     public static Alias build(Logger logger,
@@ -453,7 +454,8 @@
      * cached data has changed (see [EMAIL PROTECTED] 
org.apache.tapestry.internal.services.CheckForUpdatesFilter}).
      * <dt>ErrorFilter</dt> <dd>Catches request errors and lets the [EMAIL 
PROTECTED] org.apache.tapestry.services.RequestExceptionHandler}
      * handle them</dd> <dt>Localization</dt> <dd>Determines the locale for 
the current request from header data or
-     * cookies in the request</dd> </dl>
+     * cookies in the request</dd> <dt>IgnoredPaths</dt> <dd>Forces Tapestry 
to ignore paths, based on regular
+     * expressions contributed to the IgnoredPathsFilter service.  Ordered 
after StaticFiles.</dd> </dl>
      */
     public void contributeRequestHandler(OrderedConfiguration<RequestFilter> 
configuration, Context context,
 
@@ -467,7 +469,10 @@
                                          @IntermediateType(TimeInterval.class)
                                          long updateTimeout,
 
-                                         LocalizationSetter localizationSetter)
+                                         LocalizationSetter localizationSetter,
+
+                                         @InjectService("IgnoredPathsFilter")
+                                         RequestFilter ignoredPathsFilter)
     {
         RequestFilter staticFilesFilter = new StaticFilesFilter(context);
 
@@ -498,6 +503,8 @@
             }
         };
 
+        configuration.add("IgnoredPaths", ignoredPathsFilter, 
"after:StaticFiles");
+
         configuration.add("ErrorFilter", errorFilter);
 
         configuration.add("CheckForUpdates",
@@ -1635,7 +1642,7 @@
 
         
configuration.add(TapestryConstants.SUPPRESS_REDIRECT_FROM_ACTION_REQUESTS_SYMBOL,
 "false");
 
-        configuration.add(TapestryConstants.FORCE_FULL_URIS_SYMBOL, "false");
+        configuration.add(TapestryConstants.FORCE_ABSOLUTE_URIS_SYMBOL, 
"false");
 
         // This is designed to make it easy to keep synchronized with 
script.aculo.ous. As we
         // support a new version, we create a new folder, and update the path 
entry. We can then

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
 Sat Jan 19 09:54:10 2008
@@ -979,4 +979,9 @@
     {
         expect(tracker.getInput(field)).andReturn(input);
     }
+
+    protected final void train_isXHR(Request request, boolean isXHR)
+    {
+        expect(request.isXHR()).andReturn(isXHR).atLeastOnce();
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt 
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/conf.apt Sat Jan 
19 09:54:10 2008
@@ -70,7 +70,7 @@
   would be org.example.myapp.services.AppModule.
   
   If such a class exists, it is added to the IoC Registry. It is not an error 
for your application to not have a module, though
-  any non-trivial application will likely have one.
+  any non-trivial application will have a module.
   
 * Configuration Symbols
 
@@ -82,10 +82,9 @@
   These symbols are always defined in terms of strings, that are coerced to 
the appropriate type (a number,
   a boolean, etc.).  Of special note are <time intervals>, which are specified 
in a
   {{{../../apidocs/org/apache/tapestry/ioc/util/TimeInterval.html}particular 
format}}.
-
   
   [tapestry.default-cookie-max-age]
-    The default time period that cookies created by Tapestry will be kept in 
the client web browser.
+    The default time interval that cookies created by Tapestry will be kept in 
the client web browser.
     The dfault value is equal to one week. 
     
     Primarily, this is used with a cookie that exists 
@@ -102,23 +101,23 @@
     The default is org/apache/tapestry/default.css, stored on the classpath.
   
   [tapestry.file-check-interval]
-    Time period between file system checks. During a file system check, only a 
single thread is active (all others
+    Time interval between file system checks. During a file system check, only 
a single thread is active (all others
     are blocked) and any files loaded are checked for changes (this is part of 
{{{reload.html}automatic component reloading}}).
 
     The default is "1 s" (one second),  and is usually overridden with a 
higher value in production (say, between one and five minutes).
 
   [tapestry.file-check-update-timeout]
-    Time period that Tapestry will wait to obtain the exclusive lock needed 
for a file check. The default is "50 ms" (50 milliseconds).
+    Time interval that Tapestry will wait to obtain the exclusive lock needed 
for a file check. The default is "50 ms" (50 milliseconds).
 
     If the exclusive lock can't be obtained in that amount of time, the 
request will proceeed normally (without the check),
     but each successive request will attempt to get the lock and perform the 
check until successful.
 
-  [tapestry.force-full-uris]
-     A flag (true or false). When false (the default), Tapestry will attempt 
to optimize URLs that it generates, using
-     relative URLs when such URLs are shorter than complete URLs.  You will 
see some savings when you make generous
+  [tapestry.force-absolute-uris]
+     A flag (true or false). When false (the default), Tapestry will attempt 
to optimize URIs that it generates, using
+     relative URIs when such URIs are shorter than absolute URIs.  You will 
see some savings when you make generous
      use of libraries, sub-folders and page activation contexts ... otherwise, 
no significant difference.
 
-     When true, all URLs will be complete URLs (including the
+     When true, all URIs will be absolute URIs (including the
      context path, and the complete path for the request).
 
   [tapestry.scriptaculous]
@@ -130,7 +129,7 @@
     The time interval that an instantiated page instance may be cached before 
being removed. As pages are
     returned to the pool, they are time stamped. Periodically (as per the file 
check interval),
     the pool is scanned for page instances that have not been used recently; 
those that are outside
-    the active window are discarded.  This is used to help free up unnecessary 
page instances after
+    the active window are discarded.  This is used to free up unnecessary page 
instances after
     a request surge.
 
     The default is "10 m" (10 minutes).
@@ -151,15 +150,15 @@
     Tapestry will wait a short period of time (the soft wait interval) to see 
if an existing page instance
     is made available.  It will then create a new page instance (unless the 
hard limit has been reached).
 
-    The default is 5 page instances.
+    The default is 5 page instances.    Remember that page pooling is done 
seperately for each
+    page (and localization of the page).  
 
   [tapestry.page-pool.soft-wait]
-    The time interval that Tapestry will wait for a page instance to come 
available before deciding whether to create
-    a new instance.  The default is "10 ms".
+    The time interval that Tapestry will wait for a page instance to become 
available before deciding whether to create
+    an entirely new page instance.  The default is "10 ms".
 
   [tapestry.start-page-name]
-    The logical name of the start page, the page that is rendered for the 
<root URL>.  This is normally "start".
-    
+    The logical name of the start page, the page that is rendered for the 
<root URL>.  This is normally "start".    
 
   [tapestry.supported-locales]
     A comma-separated list of supported locales.  Incoming requests as 
"narrowed" to one of these locales, based on closest match.
@@ -179,3 +178,33 @@
     is sent directly for the action request, no redirect in the middle. This 
option should be used with care,
     and only in cases where you are certain that the benefits outweigh the 
disadvantages.
 
+
+Ignored Paths
+
+  In some cases, you may use Tapestry is concert with other servlets.  This 
can cause problems, since
+  Tapestry (being a servlet filter) may see URLs intended for another servlet 
and attempt to process them.
+
+  The Servlet API does not provide Tapestry with any clues about what other 
servlets are available in the
+  web application.  Instead, you must configure Tapestry to ignore paths 
intended for other servlets.
+
+  The IgnoredPathsFilter service is the method for this kind of configuration. 
 Its configuration
+  is an unordered collection of regular expression patterns.  A request whose 
path matches any of these
+  patterns is <<not>> processed by Tapestry.
+
+  For example, say you are using {{{http://getahead.org/dwr/}Direct Web 
Remoting}}.  You'll likely have
+  the servlet path /dwr mapped to the Direct Web Remoting servlet.
+
+  You contribution would look like:
+
+---
+  public static void contributeIgnoredPathsFilter(UnorderedCollection<String> 
configuration)
+  {
+    configuration.add("/dwr/.*");
+  }
+---
+
+  The regular expression matches any path that begins with "/dwr/".
+
+  The regular expressions provided in the configuration are always compiled 
with case insensetivity enabled.
+
+  Also note that actual files in your web application (images, stylesheets, 
etc.) are always ignored by Tapestry.
\ No newline at end of file

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java
 Sat Jan 19 09:54:10 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -41,8 +41,8 @@
 public class AppModule
 {
     /**
-     * Used to disambiguate services in this module from services in other 
modules that share the
-     * same service interface.
+     * Used to disambiguate services in this module from services in other 
modules that share the same service
+     * interface.
      */
     @Target(
             {PARAMETER, FIELD})
@@ -53,6 +53,7 @@
 
     }
 
+    @Marker(Local.class)
     public RequestFilter buildTimingFilter(final Logger log)
     {
         return new RequestFilter()

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/IgnoredPathsFilterTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/IgnoredPathsFilterTest.java?rev=613433&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/IgnoredPathsFilterTest.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/IgnoredPathsFilterTest.java
 Sat Jan 19 09:54:10 2008
@@ -0,0 +1,73 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed 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.tapestry.internal.services;
+
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.RequestFilter;
+import org.apache.tapestry.services.RequestHandler;
+import org.apache.tapestry.services.Response;
+import org.apache.tapestry.test.TapestryTestCase;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+public class IgnoredPathsFilterTest extends TapestryTestCase
+{
+    @Test
+    public void no_match() throws IOException
+    {
+        Request request = mockRequest();
+        Response response = mockResponse();
+        RequestHandler handler = mockRequestHandler();
+
+        train_getPath(request, "/barney");
+
+        train_service(handler, request, response, true);
+
+        List<String> configuration = CollectionFactory.newList("/fred");
+
+
+        replay();
+
+        RequestFilter filter = new IgnoredPathsFilter(configuration);
+
+        assertTrue(filter.service(request, response, handler));
+
+        verify();
+    }
+
+    @Test
+    public void path_excluded() throws Exception
+    {
+        Request request = mockRequest();
+        Response response = mockResponse();
+        RequestHandler handler = mockRequestHandler();
+
+        train_getPath(request, "/barney/rubble");
+
+        List<String> configuration = CollectionFactory.newList("/barney.*");
+
+        replay();
+
+        RequestFilter filter = new IgnoredPathsFilter(configuration);
+
+        assertFalse(filter.service(request, response, handler));
+
+        verify();
+    }
+
+}

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java
 Sat Jan 19 09:54:10 2008
@@ -218,7 +218,7 @@
 
 
     @Test
-    public void force_full_uri()
+    public void force_absolute_uri()
     {
         RequestPathOptimizer optimizer = mockRequestPathOptimizer();
         Response response = mockResponse();
@@ -233,7 +233,7 @@
                                  new ComponentInvocationImpl(new 
OpaqueConstantTarget("foo"), new String[0], null),
                                  false);
 
-        assertEquals(link.toFullURI(), ENCODED);
+        assertEquals(link.toAbsoluteURI(), ENCODED);
 
 
         verify();

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestPathOptimizerImplTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestPathOptimizerImplTest.java?rev=613433&r1=613432&r2=613433&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestPathOptimizerImplTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestPathOptimizerImplTest.java
 Sat Jan 19 09:54:10 2008
@@ -96,7 +96,7 @@
     }
 
     @Test
-    public void force_full_is_a_pass_through()
+    public void force_absolute_is_a_pass_through()
     {
         Request request = mockRequest();
         String path = "/some/path";
@@ -112,8 +112,4 @@
         verify();
     }
 
-    private void train_isXHR(Request request, boolean isXHR)
-    {
-        expect(request.isXHR()).andReturn(isXHR).atLeastOnce();
-    }
 }


Reply via email to