Author: remm
Date: Sun Jun 17 10:21:26 2007
New Revision: 548078

URL: http://svn.apache.org/viewvc?view=rev&rev=548078
Log:
- Method names changes after various comments (and my own personal opinion too).

Modified:
    tomcat/sandbox/comet/java/org/apache/catalina/CometEvent.java
    tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java
    tomcat/sandbox/comet/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/sandbox/comet/java/org/apache/catalina/connector/Request.java
    tomcat/sandbox/comet/java/org/apache/catalina/valves/ErrorReportValve.java
    tomcat/sandbox/comet/java/org/apache/coyote/ActionCode.java
    tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java

Modified: tomcat/sandbox/comet/java/org/apache/catalina/CometEvent.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/catalina/CometEvent.java?view=diff&rev=548078&r1=548077&r2=548078
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/catalina/CometEvent.java (original)
+++ tomcat/sandbox/comet/java/org/apache/catalina/CometEvent.java Sun Jun 17 
10:21:26 2007
@@ -33,8 +33,9 @@
 
     /**
      * Enumeration describing the major events that the container can invoke 
-     * the CometProcessors event() method with
-     * BEGIN - will be called at the beginning 
+     * the CometProcessor event() method with:
+     * <ul>
+     * <li>BEGIN - will be called at the beginning 
      *  of the processing of the connection. It can be used to initialize any 
relevant 
      *  fields using the request and response objects. Between the end of the 
processing 
      *  of this event, and the beginning of the processing of the end or error 
events,
@@ -42,8 +43,8 @@
      *  Note that the response object and depedent OutputStream and Writer are 
still 
      *  not synchronized, so when they are accessed by multiple threads, 
      *  synchronization is mandatory. After processing the initial event, the 
request 
-     *  is considered to be committed.
-     * READ - This indicates that input data is available, and that one read 
can be made
+     *  is considered to be committed.</li>
+     * <li>READ - This indicates that input data is available, and that one 
read can be made
      *  without blocking. The available and ready methods of the InputStream or
      *  Reader may be used to determine if there is a risk of blocking: the 
servlet
      *  should read while data is reported available. When encountering a read 
error, 
@@ -53,38 +54,37 @@
      *  Alternately, it is also possible to catch any exception, perform clean 
up
      *  on any data structure the servlet may be using, and using the close 
method
      *  of the event. It is not allowed to attempt reading data from the 
request 
-     *  object outside of the execution of this method.
-     * END - End may be called to end the processing of the request. Fields 
that have
+     *  object outside of the execution of this method.</li>
+     * <li>END - End may be called to end the processing of the request. 
Fields that have
      *  been initialized in the begin method should be reset. After this event 
has
      *  been processed, the request and response objects, as well as all their 
dependent
-     *  objects will be recycled and used to process other requests. End will 
also be 
-     *  called when data is available and the end of file is reached on the 
request input
-     *  (this usually indicates the client has pipelined a request).
-     * ERROR - Error will be called by the container in the case where an IO 
exception
+     *  objects will be recycled and used to process other requests.</li>
+     * <li>ERROR - Error will be called by the container in the case where an 
IO exception
      *  or a similar unrecoverable error occurs on the connection. Fields that 
have
      *  been initialized in the begin method should be reset. After this event 
has
      *  been processed, the request and response objects, as well as all their 
dependent
-     *  objects will be recycled and used to process other requests.
-     * CALLBACK - Callback will be called by the container after the comet 
processor
-     *  has registered for the OP_CALLBACK operation.
+     *  objects will be recycled and used to process other requests.</li>
+     * <li>EVENT - Event will be called by the container after the resume() 
method is called.
      *  This allows you get an event instantly, and you can perform IO actions
-     *  or close the Comet connection.
-     * WRITE - Write is called, only if the Comet processor has registered for 
the OP_WRITE
-     *  event. This means that connection is ready to receive data to be 
written out.
-     */
-    public enum EventType {BEGIN, READ, END, ERROR, WRITE, CALLBACK}
+     *  or close the Comet connection.</li>
+     * <li>WRITE - Write is sent if the servlet is using the ready method. 
This means that 
+     *  the connection is ready to receive data to be written out.</li>
+     * </ul>
+     */
+    public enum EventType {BEGIN, READ, END, ERROR, WRITE, EVENT}
     
     
     /**
-     * Event details
-     * TIMEOUT - the connection timed out (sub type of ERROR); note that this 
ERROR type is not fatal, and
-     *   the connection will not be closed unless the servlet uses the close 
method of the event
-     * CLIENT_DISCONNECT - the client connection was closed (sub type of ERROR)
-     * IOEXCEPTION - an IO exception occurred, such as invalid content, for 
example, an invalid chunk block (sub type of ERROR)
-     * WEBAPP_RELOAD - the webapplication is being reloaded (sub type of END)
-     * SERVER_SHUTDOWN - the server is shutting down (sub type of END)
-     * SESSION_END - the servlet ended the session (sub type of END)
-
+     * Event details:
+     * <ul>
+     * <li>TIMEOUT - the connection timed out (sub type of ERROR); note that 
this ERROR type is not fatal, and
+     *   the connection will not be closed unless the servlet uses the close 
method of the event</li>
+     * <li>CLIENT_DISCONNECT - the client connection was closed (sub type of 
ERROR)</li>
+     * <li>IOEXCEPTION - an IO exception occurred, such as invalid content, 
for example, an invalid chunk block (sub type of ERROR)</li>
+     * <li>WEBAPP_RELOAD - the webapplication is being reloaded (sub type of 
END)</li>
+     * <li>SERVER_SHUTDOWN - the server is shutting down (sub type of END)</li>
+     * <li>SESSION_END - the servlet ended the session (sub type of END)</li>
+     * </ul>
      */
     public enum EventSubType { TIMEOUT, CLIENT_DISCONNECT, IOEXCEPTION, 
WEBAPP_RELOAD, SERVER_SHUTDOWN, SESSION_END }
     
@@ -134,48 +134,56 @@
      * This method sets the timeout in milliseconds of idle time on the 
connection.
      * The timeout is reset every time data is received from the connection or 
data is flushed
      * using <code>response.flushBuffer()</code>. If a timeout occurs, the 
-     * servlet will receive an ERROR/TIMEOUT event. 
+     * servlet will receive an ERROR/TIMEOUT event which will not result in 
automatically closing
+     * the event (the event may be closed using the close() method).
      * 
      * @param timeout The timeout in milliseconds for this connection, must be 
a positive value, larger than 0
      */
     public void setTimeout(int timeout);
 
     /**
-     * Returns true if write notifications are disabled, or is they are 
enabled and data may
-     * be written to the connection (the flag becomes false when the client is 
unable to accept
-     * data fast enough). When the flag becomes false, the servlet must stop 
writing data. If there's
-     * an attempt to flush additional data to the client and data still cannot 
be written immediately,
-     * an IOException will be thrown. If calling this method returns false, it 
will also 
+     * Returns true when data may be written to the connection (the flag 
becomes false 
+     * when the client is unable to accept data fast enough). When the flag 
becomes false, 
+     * the servlet must stop writing data. If there's an attempt to flush 
additional data 
+     * to the client and data still cannot be written immediately, an 
IOException will be 
+     * thrown. If calling this method returns false, it will also 
      * request notification when the connection becomes available for writing 
again, and the  
      * servlet will recieve a write event.<br/>
      * 
-     * Note: If the servlet is not using isWriteable, and is writing its 
output inside the
-     * container threads, it is not needed to call this method. Any incomplete 
writes will be
+     * Note: If the servlet is not using ready, and is writing its output 
inside the
+     * container threads, using this method is not mandatory, but any 
incomplete writes will be
      * performed again in blocking mode.
      * 
      * @return boolean true if you can write to the response 
      */
-    public boolean isWriteable();
+    public boolean ready();
 
     /**
-     * Returns true if the Comet connection is blocking or non blocking and 
data is available to be read.
-     * If attempting to read in non blocking mode and this flag is false, an 
IO exception will occur.
-     * 
-     * @see javax.servlet.ServletRequest#getInputStream()#available()>0
-     * @return boolean
+     * Suspend processing of the connection until the configured timeout 
occurs, or resume() is called. In
+     * parctice, this means the servlet will no longer recieve read events. 
Reading should always be
+     * performed synchronously in the Tomcat threads unless the connection has 
been suspended.
      */
-    public boolean isReadable();
+    public void suspend();
 
     /**
-     * Will ask the servlet container to send a notify event to the servlet, 
where the request can be processed
+     * Will ask the servlet container to send a generic event to the servlet, 
where the request can be processed
      * synchronously (for example, it is possible to use this to complete the 
request after some asynchronous
-     * processing is done).
-     */
-    public void callback();
-
-    /**
-     * Delay processing of the connection until the configured timeout occurs, 
or callback() is called.
+     * processing is done). This also resumes read events if they had been 
disabled using suspend (it is possible
+     * to call suspend again). It is possible to call resume without calling 
suspend before.
      */
-    public void sleep();
+    public void resume();
 
 }
+
+/**
+ * Returns true if data is available to be read. If attempting to read and 
this flag is false, 
+ * an IO exception will occur.
+ * 
+ * <!--Note: If the servlet is not using isReadable, and is reading data 
inside the
+ * container threads, it is not needed to call this method. Any such read will 
be
+ * performed again in blocking mode.-->
+ * 
+ * @see javax.servlet.ServletRequest#getInputStream()#available()>0
+ * @return boolean
+ */
+//public boolean isReadable();

Modified: 
tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java?view=diff&rev=548078&r1=548077&r2=548078
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/catalina/connector/CometEventImpl.java 
Sun Jun 17 10:21:26 2007
@@ -113,39 +113,16 @@
         request.setTimeout(timeout);
     }
     
-    public boolean isReadable() {
-        return request.isReadable();
-    }
-
-    /**
-     * Returns true if write notifications are disabled, or is they are 
enabled and data may
-     * be written to the connection (the flag becomes false when the client is 
unable to accept
-     * data fast enough). When the flag becomes false, the servlet must stop 
writing data. If there's
-     * an attempt to flush additional data to the client and data still cannot 
be written immediately,
-     * an IOException will be thrown. If calling this method returns false, it 
will also 
-     * request notification when the connection becomes available for writing 
again, and the  
-     * servlet will recieve a write event.
-     * 
-     * @return boolean true if you can write to the response 
-     */
-    public boolean isWriteable() {
+    public boolean ready() {
         return response.isWriteable();
     }
     
-    /**
-     * Will ask the servlet container to send a notify event to the servlet, 
where the request can be processed
-     * synchronously (for example, it is possible to use this to complete the 
request after some asynchronous
-     * processing is done).
-     */
-    public void callback() {
-        request.callback();
+    public void resume() {
+        request.resume();
     }
 
-    /**
-     * Delay processing of the connection until the configured timeout occurs, 
or callback is called.
-     */
-    public void sleep() {
-        request.sleep();
+    public void suspend() {
+        request.suspend();
     }
 
     public String toString() {

Modified: 
tomcat/sandbox/comet/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/catalina/connector/CoyoteAdapter.java?view=diff&rev=548078&r1=548077&r2=548078
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/catalina/connector/CoyoteAdapter.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/catalina/connector/CoyoteAdapter.java 
Sun Jun 17 10:21:26 2007
@@ -163,7 +163,7 @@
                         
request.getEvent().setEventType(CometEvent.EventType.END);
                         request.getEvent().setEventSubType(null);
                     } else {
-                        
request.getEvent().setEventType(CometEvent.EventType.CALLBACK);
+                        
request.getEvent().setEventType(CometEvent.EventType.EVENT);
                         request.getEvent().setEventSubType(null);
                     }
                 } else if (status == SocketStatus.DISCONNECT) {

Modified: tomcat/sandbox/comet/java/org/apache/catalina/connector/Request.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/catalina/connector/Request.java?view=diff&rev=548078&r1=548077&r2=548078
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/catalina/connector/Request.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/catalina/connector/Request.java Sun 
Jun 17 10:21:26 2007
@@ -2265,21 +2265,13 @@
     }
     
     
-    /**
-     * Will ask the servlet container to send a notify event to the servlet, 
where the request can be processed
-     * synchronously (for example, it is possible to use this to complete the 
request after some asynchronous
-     * processing is done).
-     */
-    public void callback() {
-        coyoteRequest.action(ActionCode.ACTION_COMET_CALLBACK, null);
+    public void resume() {
+        coyoteRequest.action(ActionCode.ACTION_COMET_RESUME, null);
     }
     
     
-    /**
-     * Delay processing of the connection until the configured timeout occurs, 
or callback is called.
-     */
-    public void sleep() {
-        coyoteRequest.action(ActionCode.ACTION_COMET_SLEEP, null);
+    public void suspend() {
+        coyoteRequest.action(ActionCode.ACTION_COMET_SUSPEND, null);
     }
     
     

Modified: 
tomcat/sandbox/comet/java/org/apache/catalina/valves/ErrorReportValve.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/catalina/valves/ErrorReportValve.java?view=diff&rev=548078&r1=548077&r2=548078
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/catalina/valves/ErrorReportValve.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/catalina/valves/ErrorReportValve.java 
Sun Jun 17 10:21:26 2007
@@ -104,7 +104,7 @@
         Throwable throwable =
             (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);
 
-        if (response.isAppCommitted()) {
+        if (response.isCommitted()) {
             return;
         }
 

Modified: tomcat/sandbox/comet/java/org/apache/coyote/ActionCode.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/coyote/ActionCode.java?view=diff&rev=548078&r1=548077&r2=548078
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/coyote/ActionCode.java (original)
+++ tomcat/sandbox/comet/java/org/apache/coyote/ActionCode.java Sun Jun 17 
10:21:26 2007
@@ -159,12 +159,12 @@
     /**
      * Ask for a callback
      */
-    public static final ActionCode ACTION_COMET_CALLBACK = new ActionCode(25);
+    public static final ActionCode ACTION_COMET_RESUME = new ActionCode(25);
     
     /**
      * Put this request to sleep (no read notifications)
      */
-    public static final ActionCode ACTION_COMET_SLEEP = new ActionCode(26);
+    public static final ActionCode ACTION_COMET_SUSPEND = new ActionCode(26);
     
     /**
      * Ask for a write callback

Modified: 
tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java?view=diff&rev=548078&r1=548077&r2=548078
==============================================================================
--- tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java 
(original)
+++ tomcat/sandbox/comet/java/org/apache/coyote/http11/Http11AprProcessor.java 
Sun Jun 17 10:21:26 2007
@@ -1219,9 +1219,10 @@
             comet = true;
         } else if (actionCode == ActionCode.ACTION_COMET_END) {
             comet = false;
-        } else if (actionCode == ActionCode.ACTION_COMET_SLEEP) {
+        } else if (actionCode == ActionCode.ACTION_COMET_SUSPEND) {
             readNotifications = false;
-        } else if (actionCode == ActionCode.ACTION_COMET_CALLBACK) {
+        } else if (actionCode == ActionCode.ACTION_COMET_RESUME) {
+            readNotifications = true;
             endpoint.getCometPoller().add(socket, timeout, false, false);
         } else if (actionCode == ActionCode.ACTION_COMET_WRITE) {
             endpoint.getCometPoller().add(socket, timeout, false, true);



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

Reply via email to