View Javadoc

1   package org.apache.geronimo.tomcat.valve;
2   
3   import java.io.IOException;
4   
5   import javax.servlet.ServletException;
6   
7   import org.apache.catalina.Valve;
8   import org.apache.catalina.connector.Request;
9   import org.apache.catalina.connector.Response;
10  import org.apache.catalina.valves.ValveBase;
11  import org.apache.geronimo.tomcat.interceptor.BeforeAfter;
12  
13  public class GeronimoBeforeAfterValve extends ValveBase{
14      
15      private final BeforeAfter beforeAfter;
16      private final int contextIndexCount;
17  
18      public GeronimoBeforeAfterValve(BeforeAfter beforeAfter, int contextIndexCount) {
19          this.beforeAfter = beforeAfter;
20          this.contextIndexCount = contextIndexCount;
21      }
22  
23      public void invoke(Request request, Response response) throws IOException, ServletException {
24          Object context[] = new Object[contextIndexCount];
25          
26          if (beforeAfter != null){
27              beforeAfter.before(context, request, response);
28          }
29          
30          // Pass this request on to the next valve in our pipeline
31          getNext().invoke(request, response);
32          
33          if (beforeAfter != null){
34              beforeAfter.after(context, request, response);
35          }
36          
37      }
38  
39  }