Hello,

This is in regarding the addition of support for invoking Servlet 
Filters on RequestDispatcher.forwards and RequestDispatcher.includes as 
specfied in the Servlet 2.4 specification Section SRV.6.2.5.

Basically the patch enables a web application to apply filters using a 
new element under the filter-mapping elment of  the web deployment 
descriptor. Elements include REQUEST, FORWARD, and INCLUDE. Based on the 
dispatcher element(s) specified a application will or will not appy 
filters when processing a request. Please see the specification for 
furter details.

In order for this functionality to be enabled the following filles 
needed modifcation:

  org.apache.catalina.core.ApplicationDispatcher.java
  org.apache.catalina.core.StandardWrapperValue.java
  org.apache.catalina.startup.WebRuleSet.java
  org.apache.catalina.deploy.FilterMap.java

One new file was created:

  org.apache.catalina.core.ApplicationFilterFactory.java

Basically I moved all re-usable code related to creating an 
ApplicationFilterChain object into the ApplicationFilterFactory. This 
design will allow for the caching of ApplicationFilterChains in the future.

Attached are the diff files for the changes I am proposing and also the 
new file ApplicationFilterFactory.java

Pleease let me know what you all think about these changes.

Regards,

Greg Murray




Attachment: ApplicationDispat29a793eb
Description: application/text

Attachment: ApplicationFilterc0664a84
Description: application/text

--- FilterMap.java.orig Thu Jul 18 09:48:05 2002
+++ FilterMap.java      Mon Aug 19 11:12:28 2002
@@ -88,7 +88,23 @@
      * The name of this filter to be executed when this mapping matches
      * a particular request.
      */
-    private String filterName = null;
+    //added by Greg Murray
+    
+    public static final int FORWARD =1;
+    public static final int FORWARD_INCLUDE =2;
+    public static final int INCLUDE  =3;
+    public static final int REQUEST = 4;
+    public static final int REQUEST_FORWARD =5;
+    public static final int REQUEST_INCLUDE =6;
+    public static final int REQUEST_FORWARD_INCLUDE =7;
+    
+    // represents nothing having been set. This will be seen 
+    // as equal to a REQUEST
+    private static final int NOT_SET = -1;
+    
+    private int dispatcherMapping=NOT_SET;
+    
+    private String filterName = null;    
 
     public String getFilterName() {
         return (this.filterName);
@@ -124,6 +140,59 @@
 
     public void setURLPattern(String urlPattern) {
         this.urlPattern = RequestUtil.URLDecode(urlPattern);
+    }
+    
+    /**
+     * Added by Greg Murray
+     *
+     * This method will be used to set the current state of the FilterMap
+     * representing the state of when filters should be applied:
+     *
+     *        FORWARD
+     *        FORWARD_INCLUDE
+     *        INCLUDE
+     *        REQUEST
+     *        REQUEST_INCLUDE,
+     *        REQUEST_FORWARD,
+     *        REQUEST_FORWARD_INCLUDE
+     *
+     */
+    public void setDispatcher(String dispatcherString) {
+        String dispatcher = dispatcherString.toUpperCase();
+        
+        if (dispatcher.equals("FORWARD")) {
+
+            // apply FORWARD to the global dispatcherMapping.
+            switch (dispatcherMapping) {
+                case INCLUDE  :  dispatcherMapping = FORWARD_INCLUDE; break;
+                case NOT_SET  :  dispatcherMapping = FORWARD; break;
+                case REQUEST : dispatcherMapping = REQUEST_FORWARD; break;
+                case REQUEST_INCLUDE : dispatcherMapping = REQUEST_FORWARD_INCLUDE; 
+break;
+            }
+        } else if (dispatcher.equals("INCLUDE")) {
+            // apply INCLUDE to the global dispatcherMapping.
+            switch (dispatcherMapping) {
+                case FORWARD  :  dispatcherMapping = FORWARD_INCLUDE; break;
+                case NOT_SET  :  dispatcherMapping = INCLUDE; break;
+                case REQUEST : dispatcherMapping = REQUEST_INCLUDE; break;
+                case REQUEST_FORWARD : dispatcherMapping = REQUEST_FORWARD_INCLUDE; 
+break;
+            }
+        } else if (dispatcher.equals("REQUEST")) {
+            // apply REQUEST to the global dispatcherMapping.
+            switch (dispatcherMapping) {
+                case FORWARD  :  dispatcherMapping = REQUEST_FORWARD; break;
+                case INCLUDE  :  dispatcherMapping = REQUEST_INCLUDE; break;
+                case NOT_SET  :  dispatcherMapping = REQUEST; break;
+                case FORWARD_INCLUDE : dispatcherMapping = REQUEST_FORWARD_INCLUDE; 
+break;
+            }
+        }
+    }
+    
+    public int getDispatcherMapping() {
+        // per the SRV.6.2.5 absence of any dispatcher elements is
+        // equivelant to a REQUEST value
+        if (dispatcherMapping == NOT_SET) return REQUEST;
+        else return dispatcherMapping; 
     }
 
 


--- WebRuleSet.java.orig        Fri Aug  9 09:22:36 2002
+++ WebRuleSet.java     Tue Aug 13 14:41:22 2002
@@ -258,6 +258,10 @@
                                "setServletName", 0);
         digester.addCallMethod(prefix + "web-app/filter-mapping/url-pattern",
                                "setURLPattern", 0);
+        
+        // added by Greg Murray
+        digester.addCallMethod(prefix + "web-app/filter-mapping/dispatcher",
+                               "setDispatcher", 0);
 
         digester.addCallMethod(prefix + "web-app/listener/listener-class",
                                "addApplicationListener", 0);


Attachment: StandardWrapperVa6c84400b
Description: application/text

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to