You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/01/01 03:36:00 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Handler.java
costin 00/12/31 18:36:00
Modified: src/share/org/apache/tomcat/core Handler.java
Log:
Renamed Handler.doService() to Handler.invoke().
Added comments and get/set Next/Prev for handlers that act as Valves.
Same thing can be implemented in a ValveHandler ( that will be part
of the module using valves ), but it's better to make clear in the
core Handler that this mechanism is possible ( and simplify the life of
whoever wants to use/reuse valves ). It's also a safety feature for tomcat
extensibility - in case something is missing in the current hooks ( and
we don't want/can't add more hooks )
Revision Changes Path
1.35 +45 -6 jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java
Index: Handler.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- Handler.java 2000/12/29 20:31:28 1.34
+++ Handler.java 2001/01/01 02:36:00 1.35
@@ -128,7 +128,10 @@
// Debug
protected int debug=0;
protected Log logger=null;
+ Handler next;
+ Handler prev;
+
private Counters cntr=new Counters(ContextManager.MAX_NOTES);
private Object notes[]=new Object[ContextManager.MAX_NOTES];
@@ -241,6 +244,32 @@
handleServiceError( req, res, serviceException );
}
+ /** A handler may either directly generate the response or it can
+ * act as a part of a pipeline. Next/Prev allow modules to generically
+ * set the pipeline.
+ *
+ * Most handlers will generate the content themself. Few handlers
+ * may prepare the request/response - one example is the Servlet
+ * handler that wraps them and calls a servlet. Modules may
+ * do choose to either hook into the server using the provided
+ * callbacks, or use a pipeline of handler ( valves ).
+ */
+ public void setNext( Handler next ) {
+ this.next=next;
+ }
+
+ public Handler getNext() {
+ return next;
+ }
+
+ public Handler getPrevious() {
+ return prev;
+ }
+
+ public void setPrevious( Handler prev ) {
+ this.prev=prev;
+ }
+
// -------------------- methods you can override --------------------
protected void handleServiceError( Request req, Response res, Throwable t )
@@ -254,16 +283,26 @@
public void reload() {
}
- /** This is the actual content generator. Can't be called
- * from outside.
- *
- * This method can't be called directly, you must use service(),
- * which also tests the initialization and deals with the errors.
- */
+ // Old name, deprecated
protected void doService(Request req, Response res)
throws Exception
{
+ }
+
+ /** This is the actual content generator. A handler must generate
+ * the response - either itself or by calling another class, after
+ * setting/changing request properties or altering/wrapping
+ * the request and response.
+ *
+ * A Handler should use the "next" property if it is part
+ * of a pipeline ( "valve")
+ */
+ protected void invoke(Request req, Response res)
+ throws Exception
+ {
+ // backward compatibility
+ doService(req, res);
}
// -------------------- Debug --------------------