remm 02/04/04 07:02:13
Modified: catalina/src/share/org/apache/catalina/core
StandardPipeline.java
Log:
- Refactor the pipeline valve context using comments from Christopher St John.
Revision Changes Path
1.6 +67 -62
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardPipeline.java
Index: StandardPipeline.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardPipeline.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StandardPipeline.java 1 Apr 2002 04:19:54 -0000 1.5
+++ StandardPipeline.java 4 Apr 2002 15:02:13 -0000 1.6
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardPipeline.java,v
1.5 2002/04/01 04:19:54 remm Exp $
- * $Revision: 1.5 $
- * $Date: 2002/04/01 04:19:54 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardPipeline.java,v
1.6 2002/04/04 15:02:13 remm Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/04/04 15:02:13 $
*
* ====================================================================
*
@@ -97,13 +97,7 @@
*/
public class StandardPipeline
- implements Pipeline, Contained, Lifecycle, ValveContext {
-
-
- // -------------------------------------------------------------- Constants
-
-
- protected static final String STATE = "pipelineState";
+ implements Pipeline, Contained, Lifecycle {
// ----------------------------------------------------------- Constructors
@@ -472,11 +466,8 @@
public void invoke(Request request, Response response)
throws IOException, ServletException {
- // Initialize the per-thread state for this thread
- request.setNote(STATE, new PipelineState());
-
// Invoke the first Valve in this pipeline for this request
- invokeNext(request, response);
+ (new StandardPipelineValveContext()).invokeNext(request, response);
}
@@ -534,51 +525,6 @@
}
- // --------------------------------------------------- ValveContext Methods
-
-
- /**
- * Cause the <code>invoke()</code> method of the next Valve that is part of
- * the Pipeline currently being processed (if any) to be executed, passing
- * on the specified request and response objects plus this
- * <code>ValveContext</code> instance. Exceptions thrown by a subsequently
- * executed Valve (or a Filter or Servlet at the application level) will be
- * passed on to our caller.
- *
- * If there are no more Valves to be executed, an appropriate
- * ServletException will be thrown by this ValveContext.
- *
- * @param request The request currently being processed
- * @param response The response currently being created
- *
- * @exception IOException if thrown by a subsequent Valve, Filter, or
- * Servlet
- * @exception ServletException if thrown by a subsequent Valve, Filter,
- * or Servlet
- * @exception ServletException if there are no further Valves configured
- * in the Pipeline currently being processed
- */
- public void invokeNext(Request request, Response response)
- throws IOException, ServletException {
-
- // Identify the current subscript for the current request thread
- PipelineState pipelineState = (PipelineState) request.getNote(STATE);
- int subscript = pipelineState.stage;
- pipelineState.stage = pipelineState.stage + 1;
-
- // Invoke the requested Valve for the current request thread
- if (subscript < valves.length) {
- valves[subscript].invoke(request, response, this);
- } else if ((subscript == valves.length) && (basic != null)) {
- basic.invoke(request, response, this);
- } else {
- throw new ServletException
- (sm.getString("standardPipeline.noValve"));
- }
-
- }
-
-
// ------------------------------------------------------ Protected Methods
@@ -625,13 +571,72 @@
}
- // ---------------------------------------------- PipelineState Inner Class
+ // ------------------------------- StandardPipelineValveContext Inner Class
+
+
+ protected class StandardPipelineValveContext
+ implements ValveContext {
+
+
+ // ------------------------------------------------- Instance Variables
- protected class PipelineState {
+ protected int stage = 0;
- int stage = 0;
+ // --------------------------------------------------------- Properties
+
+
+ /**
+ * Return descriptive information about this ValveContext
+ * implementation.
+ */
+ public String getInfo() {
+ return info;
+ }
+
+
+ // ----------------------------------------------------- Public Methods
+
+
+ /**
+ * Cause the <code>invoke()</code> method of the next Valve that is
+ * part of the Pipeline currently being processed (if any) to be
+ * executed, passing on the specified request and response objects
+ * plus this <code>ValveContext</code> instance. Exceptions thrown by
+ * a subsequently executed Valve (or a Filter or Servlet at the
+ * application level) will be passed on to our caller.
+ *
+ * If there are no more Valves to be executed, an appropriate
+ * ServletException will be thrown by this ValveContext.
+ *
+ * @param request The request currently being processed
+ * @param response The response currently being created
+ *
+ * @exception IOException if thrown by a subsequent Valve, Filter, or
+ * Servlet
+ * @exception ServletException if thrown by a subsequent Valve, Filter,
+ * or Servlet
+ * @exception ServletException if there are no further Valves
+ * configured in the Pipeline currently being processed
+ */
+ public void invokeNext(Request request, Response response)
+ throws IOException, ServletException {
+
+ int subscript = stage;
+ stage = stage + 1;
+
+ // Invoke the requested Valve for the current request thread
+ if (subscript < valves.length) {
+ valves[subscript].invoke(request, response, this);
+ } else if ((subscript == valves.length) && (basic != null)) {
+ basic.invoke(request, response, this);
+ } else {
+ throw new ServletException
+ (sm.getString("standardPipeline.noValve"));
+ }
+
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>